- monadic constructs (Option & Result)
- the error propagation operator
- the From trait, to automatically convert errors on propagation
The combination of the three features above makes up the best error handling solution I saw in a language, being simple, sound, and maintainable at the same time.
I absolutely agree with this. The error handling in Rust is fantastic to work with.
Once I learned about bullet three, error handling became less of a chore and more of non-issue while staying confident that any errors would be handled correctly.
Wanna know a quick way to reduce your compile time by several seconds? Skip proc macros that you can impl manually. The Error trait is one such case where the boilerplate impl is worth it.
Absolutely the same about bullet three! My first few Rust attempts had “map_err” all over the place and while it still felt semi-graceful it seemed like a ton of boilerplate. Learning about From was a revelation.
Comments
- monadic constructs (Option & Result) - the error propagation operator - the From trait, to automatically convert errors on propagation
I absolutely agree with this. The error handling in Rust is fantastic to work with.
Once I learned about bullet three, error handling became less of a chore and more of non-issue while staying confident that any errors would be handled correctly.
The “anyhow” and “thiserror” crates remove a lot of boilerplate, too. I hope something like that gets merged into std.
Wanna know a quick way to reduce your compile time by several seconds? Skip proc macros that you can impl manually. The Error trait is one such case where the boilerplate impl is worth it.
Absolutely the same about bullet three! My first few Rust attempts had “map_err” all over the place and while it still felt semi-graceful it seemed like a ton of boilerplate. Learning about From was a revelation.