3 ms·
Rust does allow you to easily call functions or methods that may error by using the `?` operator (formerly `try!` macro) https://doc.rust-lang.org/std/macro.tr
by spion 4y ago
Rust does allow you to easily call functions or methods that may error by using the `?` operator (formerly `try!` macro)
https://doc.rust-lang.org/std/macro.try.html https://doc.rust-lang.org/std/macro.try.html
You can also implement `From` (see `impl From` in the above doc) to define how you want external error types to be converted.
Its one of the rare languages where there isn't much boilerplate involved in using `Result`-style errors, even compared to exceptions (Swift is like this too)
There is even backtrace support for Result types: https://docs.rs/trace-error/latest/trace_error/ https://docs.rs/trace-error/latest/trace_error/