"Rustacean", pronounced like "crustacean" without the initial 'c'; remember that Rust's logo is a crab (named Ferris).
Also, regarding ".except": like ".unwrap", you almost never want to use it, because it panics on failure. Instead, you can write:
let file = File::open(&input_filename)?;
That will propagate the error upwards; if you propagate an error out of main, Rust will print an error message and exit with exit code 1, which is often what you want. Some error handling libraries also let you add context to the error before propagating it.`expect` takes an input that is either an error or a value, then turns that input into just a value. The provided string is the error message if something goes wrong (i.e. the input was an error).
enum Result<T, E> {
Ok(T),
Err(E),
}
Opening a file can, of course, fail for whatever reason, so `File::open` returns a `Result`. The `expect` method in that example is one defined on `Result` which takes that result and a message string, and if it's the `Ok` variant will return the value stored that variant. If its the `Err` variant it will print the input string and start an unrecoverable [1] panic, ending the program.You would typically use `expect` (or `unwrap`, which does the same thing but without a custom message) when you either know for certain that it can't fail, or the failure condition is not something the program can recover from.
[0] Full definition can be found at https://doc.rust-lang.org/std/result/enum.Result.html
[1] Technically, you can catch a panic unwind [2], but it's more awkward and intended more for FFI boundaries than normal code. There's also no guarantee that the program will unwind. The compiler might have been set to abort on a panic instead of unwinding, in which case there's no unwind to catch.
[2] https://doc.rust-lang.org/std/panic/fn.catch_unwind.html
See also the definition of expect: https://doc.rust-lang.org/std/result/enum.Result.html#method...
2. Perhaps a different page for each chapter/part would have been nice.
3. I wonder how different would a C++ "taste-teaser" with the same scope and goal be.
4. I'm not a Rustian (Rustic? Rust-guy?); this seems strange to me:
why am I expecting an error? Shouldn't that keyword be "on_exception" or something?