News for hackers. Stuff that matters.
Re:Announcing Rust 1.22 by drewm1980 on Thursday November 23, 2017 @02:04AM (#15763366)
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!
Re:Announcing Rust 1.22 by GolDDranks on Thursday November 23, 2017 @03:05AM (#15763605)
It'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.
Re:Announcing Rust 1.22 by Manishearth on Thursday November 23, 2017 @07:17AM (#15764538)
Nah, 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`.