Note. The specifics in this answer regarding read_line and ~str apply to Rust prior to version 1.0. The general concepts of unwrap and unwrap_or remain relevant.
Since read_line may fail, it returns Option<~str> . To get the value, you can use pattern matching or one of the reversal methods.
The difference between unwrap and unwrap_or is that unwrap will fail if there is no value ( None ), but unwrap_or will return the specified default value ("nothing" in this case)
Arjan Jan 21 '14 at 12:21 2014-01-21 12:21
source share