On 07/12/2013 01:14, Huon Wilson wrote:
I personally think a better solution is something like Haskell's do notation[1], where you can chain several computations that return Option<..> such that if any intermediate one returns None, the later ones are not evaluated and the whole expression returns None, which saves having to call .get()/.unwrap()/.expect() a lot.
We have that, it’s Option’s .and_then() method.
This can work for types like Result too (in fact, the Haskell implementation of `do` is sugar around some monad functions, so any monad can be used there; we currently don't have the power to express the monad typeclass/trait in Rust so the fully general form probably isn't possible as a syntax extension yet, although a limited version is).
-- Simon Sapin _______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev