this post was submitted on 07 Aug 2025
69 points (100.0% liked)

Rust

8057 readers
54 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 3 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] sukhmel@programming.dev 2 points 10 months ago (1 children)

Wait, so you say res_res?? gives more information than res_res.flatten()?, do you?

I mean, this is a very trivial case and not best suited for flatten at all, but the information is lost in exactly the same way

[–] BB_C@programming.dev 1 points 10 months ago

Yes. Note that I'm replying to this:

messy Result type just seems like a case of something that should’ve been handled already (or properly propagated up).

My point was that without flattening, "provide context and propagate" vs. "directly propagate" is always explicit and precise, and is obviously already supported and easy to do.

Use with functional chaining, as pointed out by others, wasn't lost on me either. I've been using Option::flatten() for years already, because such considerations don't exist in that case.