Hacker News new | ask | show | jobs
by masklinn 2706 days ago
FWIW Rust does not have optionals chaining, except in the monadic sense (in which case ML and Haskell have optionals chaining).

That is, in Rust you'd use Option::map or Option::and_then, there is no equivalent to the `?.` and `?[]` operators, the `?` operator (or `try!` macro) is a shortcut for an "unwrapping guard".

2 comments

Right, but isn't `?.` just syntactic sugar on `Option::and_then`? Is this a patent on a piece of syntactic sugar, or is it a patent on the idea of chaining optional values?
Ruby does seem to have the exact thing: http://mitrev.net/ruby/2015/11/13/the-operator-in-ruby/