-
Notifications
You must be signed in to change notification settings - Fork 653
Should closures of StreamExt::map and TryStream::map_{ok, err} return a Future? #1889
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
As you mentioned, there is |
@seanmonstar Yeah, but |
The equivalent is |
No, their closures return |
That makes it seem like there's a missing If you think of The difficulty with trait TryFutureExt {
// existing `map_ok`
fn map_map<T>(self, impl FnOnce(Self::Ok) -> T)
-> impl Future<Output = Result<T, Self::Err>>;
// existing `map_err`
fn map_map_err<T>(self, impl FnOnce(Self::Err) -> T)
-> impl Future<Output = Result<Self::Ok, T>>;
fn then_map<T>(self, impl FnOnce(Self::Ok) -> impl Future<Output = T>)
-> impl Future<Output = Result<T, Self::Err>>;
fn then_map_err<T>(self, impl FnOnce(Self::Err) -> impl Future<Output = T>)
-> impl Future<Output = Result<Self::Ok, T>>;
fn map_and_then<T>(self, impl FnOnce(Self::Ok) -> Result<T, Self::Err>)
-> impl Future<Output = Result<T, Self::Err>>;
fn map_or_else<T>(self, impl FnOnce(Self::Err) -> Result<Self::Ok, T>)
-> impl Future<Output = Result<Self::Ok, T>>;
// existing `and_then`
fn then_and_then<T>(self, impl FnOnce(Self::Ok) -> impl Future<Output = Result<T, Self::Err>>)
-> impl Future<Output = Result<T, Self::Err>>;
// existing `or_else`
fn then_or_else<T>(self, impl FnOnce(Self::Err) -> impl Future<Output = Result<Self::Ok, T>>)
-> impl Future<Output = Result<Self::Ok, T>>;
} (and I just realised that this is talking about |
I'm removing this from the 0.3 release milestone. I think the current API makes a sort of sense, and we very well may want more versions of these, but settling on the exact naming of each and what combinations to offer is, I think, out of reach for this release. |
Seeing that FWIW, what just happened to me is I've been told by the compiler that |
Closing in favor of #2755. |
Currently, closures of
StreamExt::map
andTryStream::{map_ok, map_err}
return a value, not a Future. It is probably preferable to change this to return a Future like any other combinator.The async closure version of map is then, but since the current Future does not return Result, I think it can be removed.
cc @cramertj @Nemo157
The text was updated successfully, but these errors were encountered: