-
Notifications
You must be signed in to change notification settings - Fork 633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Asyn
/Async
/// [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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should include into_async
so that AsyncResult
s can be await
ed (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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 {} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also want Async
for Never
.
|
||
/// Shorthand for a `Poll<Result<_, _>>` value. | ||
pub type PollResult<T, E> = Poll<Result<T, E>>; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we should also have a macro here for propagating Pending
that works on non-Result
y Poll
s.
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
Future
trait with anError
type, but uses the newPoll
type; an aliasPollResult<T, E> = Poll<Result<T, E>>
is defined.The combinators for
Future
are added back to this branch and updated with thePoll
changes, but otherwise are as in 0.2. We'll need follow up with changes to bring them into line, e.g. renamingmap
tomap_ok
etc.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.