|
|
|
|
|
by bonzini
663 days ago
|
|
Rust Result is basically a checked exception. Java makes you choose between adding an exception to "throws" or catching it, Rust makes you choose between declaring your function as returning Result or checking if you got an Err. The only difference is that Rust has better syntactic sugar for the latter, but Result is really isomorphic to Java checked exceptions. Panic could be said to be the same as an unchecked exception, except you have a lot more control on what causes them. The panic you get from calling unwrap() on an Option is the same as a NullPointerException, but you have full control on which points of the program that can generate it. |
|
https://doc.rust-lang.org/1.80.1/src/alloc/vec/mod.rs.html#1...