this post was submitted on 07 Aug 2025
71 points (100.0% liked)
Rust
7408 readers
102 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
What scenarios do you envision a Result<Result<T, E>, E> having a different meaning than a Result<T, E>? To me, the messy Result type just seems like a case of something that should've been handled already (or properly propagated up).
(stating the obvious)
You can already :
With
res_res.flatten()?
, you don't know where you got the error anymore, unless the error type itself is "flatten-aware", which is a bigger adjustment than the simple ergonomic library addition, and can become itself a problematic pattern with its own disadvantages.I think it's more for cases where you don't want to return, like
This, it's not a thing that happens often, but there were a couple of times when flatten would've been handy
This was also usually a result of a chain of
and_then
that could do with some flattening. This could've been rewritten as a separate function to make use of?
, but it seems to be a bigger trouble than use