Does anyone have an example of going from an Iterator of type Result<T, SomeError> to Iterator of type T, while handling all errors? I can see how this could be done with `for x in y` syntax, but I'm wondering if this can be done using combinators. Can it?
-
Show this thread
-
Or is this simply a limitation of combinators because closures can't return to the top-level scope, whereas blocks *can*. Ugh, my intuition is telling me it's exactly this, and I really don't like it. Or well, it could be done, but it would likely require buffering. Which is :(
1 reply 0 retweets 1 likeShow this thread -
I'm mostly just hoping I've missed something, and someone here can spot what I've missed.
1 reply 0 retweets 0 likesShow this thread -
Oops, I should've clarified: I don't mean "all errors". I mean: "keep forwarding input into a new stream, but exit on the first error". Also without buffering.
4 replies 0 retweets 0 likesShow this thread -
Replying to @yoshuawuyts
Yeah, if you just want to do a thing for each item, try_for_each is what you want. If you want to continue method chaining, It does seem like https://docs.rs/try_map/0.3.1/try_map/trait.FallibleMapExt.html … (or something similar) would be what you want. So: get_some_res_stream() .try_map(...)? .map() .map()
1 reply 0 retweets 0 likes -
Replying to @bitshiftmask
Hmm, at the risk of sounding like a broken record: wouldn't try_map still also have to do internal buffering? e.g. it can't return a Result until all items have been iterated over -- which means in the case of an infinite iterator it either OOMs or runs into an error.
1 reply 0 retweets 0 likes -
Replying to @yoshuawuyts
My hope was to do it in a way without buffering, but it honestly may not be possible without terminating the chain, like with try_for_each. I'll try to take a crack at it, but just writing down the type signatures makes me wonder if it is possible (without channels, etc).
1 reply 0 retweets 1 like
*nods*. I'm kind of thinking I may have to step back and zoom out beyond this problem entirely. The underlying problem I want to solve is "Copy data from a TryStream of Vec<u8> directly into an AsyncRead using combinators". Thinking generic enum error types may be an option.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.