2 ms·
There's o.expect("Error")?.map(f) if you just need to convert a Option to a value in-line and None is an error.
by Animats 6y ago
There's
o.expect("Error")?.map(f)
if you just need to convert a Option to a value in-line and None is an error.
- Animats 6y agoAlso the rather bulky o.ok_or_else(|| anyhow("Error"))?.map(f) I've been writing too many of those forms lately, decoding a tree data structure of known form which might be wrong, but usually isn't.
- Arnavion 6y agoI assume you meant `.ok_or`, not `.expect`. Either way, I'm not really how this or your `.ok_or_else` comment is relevant to this sub-thread. `.map` is not a method on tuples.