4 ms·
Ok so I guess it's a trinary operator with two arguments combined that is able to use Option and Result for the test... I hope autoformatters keep stuff like th
by drewm1980 9y ago
Ok so I guess it's a trinary operator with two arguments combined that is able to use Option and Result for the test... I hope autoformatters keep stuff like that on one line!
- GolDDranks 9y agoIt's an error handling operator that does an early exit in case of None and unwraps the value in case of Some. It used to work only with Result: early exit when Err, unwrapping the value when Ok.
- Manishearth 9y agoNah, in that example there should be a `return` before the `None` -- because it's the only block in the function it doesn't matter. But it's not a ternary operator, it's unary. let val = foo.bar()?; will call `bar()`, return if it is None, and if it is `Some(foo)`, set `val` to `foo`.