Rust should have the ¿ operator

228 points AverageClassic2 54 comments

Rust should support the ¿ operator, which, of course, does the opposite of the ? operator: return the Ok(T) and yield the E in Err(E).

fn fallible<T, E>() -> Result<T, E> {
    let e = something_fallible()¿;

    println!("error occured: {:?}, e);

    ... // Now we can try to recover from the error inline
}

Using el signo de interrogación invertido is a somewhat sarcastic suggestion, but either way something like this would be nice :D.