4 ms·
The `Option` type (what Rust calls Maybe) is rarely used for error handling. As the article describes, Result is normally used, which allows attaching arbitrary
by dbaupp 11y ago
The `Option` type (what Rust calls Maybe) is rarely used for error handling. As the article describes, Result is normally used, which allows attaching arbitrary data to the error case: http://doc.rust-lang.org/std/result/ http://doc.rust-lang.org/std/result/
For example, the io library generally returns http://doc.rust-lang.org/std/io/struct.Error.html http://doc.rust-lang.org/std/io/struct.Error.html as the information when errors occur, which includes all sorts of possibilities for what went wrong: http://doc.rust-lang.org/std/io/enum.ErrorKind.html http://doc.rust-lang.org/std/io/enum.ErrorKind.html
- e12e 11y agoIn addition to what dbaupp mentions, you might want to look at: http://blog.burntsushi.net/rust-error-handling/ http://blog.burntsushi.net/rust-error-handling/ (which was posted to hn a while back)