Syntax
Some cool Rust syntax
? Operator
?
Operator is used at the end of an expression returning aResult
, and is equivalent to a match expression, where theErr(err)
branch expands to an earlyreturn Err(From::from(err))
, and theOk(ok)
branch expands to anok
expression.
This also works for Option
. Check out the StackOverflow link in the references section below.
References
Examples and quotes from: Rust By Example - ?
Last updated