News for hackers. Stuff that matters.
Re:Swift – observations from Rust’s original designer by andolanra on Tuesday June 03, 2014 @03:37AM (#7838572)
You could always write this yourself with a macro:

    macro_rules! if_let {
      ($p:pat = $init:expr in $e:expr) => {
        { match $init { $p => $e,_  => {}, } }
      }
    }

    fn main() {
      let tup = (2, 3);
      if_let!{(2, x) = tup in println!("x={}", x)}; // prints x=3
      if_let!{(5, x) = tup in println!("x={}", x)}; // doesn't print
    }
It's slightly more heavyweight, but still not too bad.
Re:Swift – observations from Rust’s original designer by renox on Tuesday June 03, 2014 @05:13AM (#7838886)
Bleah, Rust's println makes my eyes bleed.. What's didn't you do 'println!("x value={x}");'?? Yes, I know you can use 'println!("x value={u}",u=x);', it still isn't a good syntax IMHO.