-
Notifications
You must be signed in to change notification settings - Fork 61
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
Change impl Future for Either
to Output = Either
#79
Comments
AsyncRead
and AsyncWrite
?futures
?
Is there a reason you're not using |
I guess we could yeah! I'll try and report back. |
It doesn't work at the moment because Edit: PR submitted here: rust-lang/futures-rs#2691 |
Another thing I just discovered is that impl<A, B> Future for Either<A, B>
where
A: Future,
B: Future<Output = A::Output>,
{
type Output = A::Output;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
match self.project() {
Either::Left(x) => x.poll(cx),
Either::Right(x) => x.poll(cx),
}
}
} I would have expected that a |
Would you be up for merging an implementation of the |
Ah, note that |
Dang so that would be a breaking change :( I guess I'll have to stick with my custom |
FWIW, a not unified output would have been more powerful because you can always call Not sure if you ever plan on doing 2.0 but that could be a consideration :) |
It's not exactly equivalent -- they can be different |
I am not sure I follow? What I meant was: impl<A, B> Future for Either<A, B> {
type Output = Either<A::Output, B::Output>;
// ...
} If Am I missing something? |
Oh, calling |
Would you like me to re-word this issue for changing the |
Sure, it wouldn't hurt to have a clean summary of proposed changes. |
futures
?impl Future for Either
to Output = Either
Done! |
Currently, the implementation of
Future
forEither
requires that bothFuture
s resolve to the same type:either/src/lib.rs
Lines 1127 to 1141 in af9f5fb
This limits, which kinds of
Future
s can be expressed usingEither
. It would be more useful to set theOutput
type toEither<A::Output, B::Output>
. This is an API breaking change.The original behaviour can be restored using the
Either::into_inner
function. In case bothFuture
s,A
andB
have the sameOutput
, theinto_inner
function can be used to "unwrap" theEither
:either/src/lib.rs
Lines 916 to 930 in af9f5fb
The text was updated successfully, but these errors were encountered: