What is this question mark operator about?
@lebyy▲ 0 net votes
Problem: I'm reading the documentation for File : //.. let mut file = File::create("foo.txt")?; //.. What is the ? in this line? I do not recall seeing it in the Rust Book before. Fix (from the top answer): As you may have noticed, Rust does not have exceptions. It has panics, but their use for error-handling is discouraged (they are meant for unrecoverable errors). In Rust, error handling uses Result . A typical example would be: fn halves_if_even(i: i32) -> Result<i32, Error> { if i % 2 == 0 { Ok(i / 2) } else {…