Note The specifics in this question regarding
read_line
and~str
pertain to a pre-1.0 version of Rust. The general concepts aboutunwrap
andunwrap_or
remain relevant.
I've encountered it while reading Rust for Rubyists i.e.:
let mut reader = BufferedReader::new(io::stdin());
let input = reader.read_line().unwrap_or(~"nothing");