-
Notifications
You must be signed in to change notification settings - Fork 309
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
residual versions of map_ok
et al
#712
Comments
The problem I see is that you want Personally, solving "Advent of Code" in rust without much "unwrap/expect", I made a super trait named
There is also EDIT: Maybe I'm just ignorant about "residual". |
Yeah, the type of the returned error should be generic. I used eyre as an example. I'm on mobile and only have a surface-level understanding of Try v2, but I suspect the type signature would look something like this: trait Itertools {
fn map_ok_residual<O1, O2, F, I>(self, f: F) -> I
where
Self: Iterator<Item = O1>,
F: FnMut(<O1 as Try>::Output) -> O2,
O1: Try,
O2: Try + FromResidual<<O1 as Try>::Residual>,
I: Iterator<Item = O2>; Try v2 is currently feature-gated (linked in the original issue) so Try and FromResidual are only available on nightly. However an Iterator like this would be pretty convenient whether I want an |
Itertools currently uses "Rust stable" only. |
it'd be really convenient if there was a version of
map_ok
that allowed the error type to be transformed via theTry
traits. notably, blocked on rust-lang/rust#84277 but it might be possible to expose as a feature flag?would be a shorthand for eg transforming an iter of
io::Result
toeyre::Result
when calling a function that returns aneyre::Result
on the ok value ofio::Result
.The text was updated successfully, but these errors were encountered: