Let Me Ask You a Question
That code in the previous lesson looks a little repetitive, doesn’t it? Match on an Option
, check if the option is None
, if it’s None
, then return None
. If it’s Some
, then evaluate to that value. Wouldn’t it be great if there was a nice, easy way to capture that idea in a much shorter amount of code?
Fortunately, there is! This idea of "None
propagation" is so common in Rust that it’s captured in a single character: ?
. Observe:
Get hands-on with 1400+ tech skills courses.