Someone mentioned try
already, but to elaborate, with the new desugar scheme I'm working on, that would be
let c = try { a?.b?.c }.unwrap_or(d);
(assuming d
is not itself also an Option
.)
I actually like that better than C#'s ?.
, because in C# that occasionally does something weird because it has a slightly-magic scope -- a?.b.Foo()
and (a?.b).Foo()
do something different, even though there's no precedence reason for the parens there. Having the block written directly in the form thus, I think, fits better for the Rust form.
But I would like to see Something for coalescing; aka generalized/improved `or_else`.