Bring 0.3 branch up to date with new RFC#986
Conversation
|
|
||
| /// An `Async` value represents an asychronous computation. | ||
| /// | ||
| /// An `Asyn` is a value that may not have finished computing yet. This kind of |
| /// [executor](../futures_core/executor/trait.Executor.html) as a new, independent | ||
| /// task that will automatically be `poll`ed to completion. | ||
| /// | ||
| /// # Combinators |
There was a problem hiding this comment.
Here and above you mention combinators on Async-- this should link to AsyncExt.
| /// This method is a stopgap for a compiler limitation that prevents us from | ||
| /// directly inheriting from the `Async` trait; in the future it won't be | ||
| /// needed. | ||
| fn poll(self: Pin<Self>, cx: &mut task::Context) -> PollResult<Self::Item, Self::Error>; |
There was a problem hiding this comment.
This should include into_async so that AsyncResults can be awaited (well, I suppose it could go on AsyncResultExt, but the method should exist somewhere). Also, i think the name of the poll method here should be poll_result so that it doesn't cause ambiguities.
| /// Create a future that is immediately ready with a value. | ||
| pub fn ready<T>(t: T) -> ReadyFuture<T> { | ||
| ReadyFuture(Some(t)) | ||
| impl<F> IntoFuture for F where F: Future { |
There was a problem hiding this comment.
I think you also want an impl<A> IntoFuture for A where A: AsyncResult + Unpin { ... }.
| /// [`err`](::future::err) functions. | ||
| #[derive(Debug, Clone)] | ||
| #[must_use = "futures do nothing unless polled"] | ||
| pub struct FutureResult<T, E> { |
There was a problem hiding this comment.
Might as well add an impl of Async + Unpin for FutureResult (same goes for all the other Future-specific combinators).
| pub fn never_into<T>(self) -> T { | ||
| match self {} | ||
| } | ||
| } |
|
|
||
| /// Shorthand for a `Poll<Result<_, _>>` value. | ||
| pub type PollResult<T, E> = Poll<Result<T, E>>; | ||
|
|
There was a problem hiding this comment.
It seems like we should also have a macro here for propagating Pending that works on non-Resulty Polls.
|
The general strategy in this PR takes is to copy all of the combinators over to |
|
Closing this out, as I'm taking a different approach now. |
This PR updates the 0.3 work to match the new RFC.
The approach here keeps the
Futuretrait with anErrortype, but uses the newPolltype; an aliasPollResult<T, E> = Poll<Result<T, E>>is defined.The combinators for
Futureare added back to this branch and updated with thePollchanges, but otherwise are as in 0.2. We'll need follow up with changes to bring them into line, e.g. renamingmaptomap_oketc.My plan is to follow this same approach to get the crates back into working condition (including tests), and then circle back to harmonize the combinators.