-
Notifications
You must be signed in to change notification settings - Fork 653
Rationalize conversions throughout combinators #291
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
Comments
Automatic conversion between error types sounds scary to me. I think we will likely want to have something like impl <T, E> ::std::ops::Carrier for Box<Future<Item=T,Error=E>> {
type Success = T;
type Error = E;
//...
} so that we can conveniently use |
Another option would be to play around with blanket I agree with @dwrensha that too many silent conversions could get unwieldy, but in general I think it's fine to inject |
With the current proposal for the This would be possible: impl QuestionMark<Async<T>, io::Error> for io::Result<T> {
fn ask(self) -> Poll<T, io::Error> {
match self {
Ok(v) => Ok(Async::Ready(v)),
Err(e) => match e.kind() {
io::ErrorKind::WouldBlock => Ok(Async::NotReady),
_ => Err(e),
}
}
}
} However, like I said, it only gets us half-way. let something = self.inner.poll()?; The above will make To get this to work, it seems 2 directions could be taken:
Of course, the choice to do neither could be taken, but seems like then we miss out on an excellent language feature, |
The |
#733 has landed on 0.2 which blanket removes |
There are a number of possible "liftings" and conversions that combinators can allow:
T
, vsResult<T, E>
, vsFuture<Item = T, Error = E>
, vsIntoFuture<Item =T, Error = E>
. The current combinators are a mix.From
/Into
.We recently added a combinator specifically for the latter.
In general, though, it'd be nice to make the combinators consistent and maximally flexible -- but it's easy to run into problems with type inference. Let's iterate on this.
The text was updated successfully, but these errors were encountered: