News for hackers. Stuff that matters.
Re:Rust for functional programmers by kzrdude on Sunday July 13, 2014 @01:12PM (#8027938)
What the for loop actually expands to is much easier to read.

    [<label>] for <pat> in <iterator expression> { ... }

    let __iterator = &mut <iterator expression>;
    <label> loop {
        match __iterator.next() {
            None => break,
            Some(<pat>) => { ... }
        }
    }
Re:Rust for functional programmers by dbaupp on Sunday July 13, 2014 @06:32PM (#8028758)
It doesn't actually expand to that any more. You can see what it does expand to by running rustc --pretty expanded with a recent compiler:

  for pattern in iterator {
      body
  }
becomes

  match &mut iterator {
      i => loop {
          match i.next() {
              None => break ,
              Some(mut _value) => { let pattern = _value; { body } }
          }
      }
  }
Re:Rust for functional programmers by sfvisser on Sunday July 13, 2014 @06:12PM (#8028700)
Much easier to read to who? Not to me at least.

Code readability is subjective and depends on experience and familiarity.

Re:Rust for functional programmers by knz42 on Monday July 14, 2014 @02:44AM (#8029744)
I did not know that for was actually expanded early in the compiler and that one could print out the expansion with --pretty expanded. Color me enlightened. I have incorporated this, thanks!