Daily Shaarli

All links of one day in a single page.

March 1, 2026

Don't Unwrap Options: There Are Better Ways | corrode Rust Consulting

Conclusion

For most cases, I prefer this syntax:

let Some(value) = some_function() else {
return Err("Descriptive error message".into());
};

To me, let-else is the best solution for handling None because:

It’s part of the standard library.
It works for both libraries and applications.
It’s easy to understand for beginners.
It’s reasonably compact.
It allows for more complex error handling logic in the else block if needed.
Learning the mechanics behind it is helpful in other places in Rust.