-
-
Save durka/49b7cbec66764221b822 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let values = vec![1, 2, 3]; | |
for x in values { | |
println!("{}", x); | |
} | |
// Rough translation of the iteration without a `for` iterator. | |
let values = vec![1, 2, 3]; | |
let mut it = values.into_iter(); | |
loop { | |
match it.next() { | |
Some(x) => println!("{}", x), | |
None => break, | |
} | |
} | |
// Actual translation (munged output of rustc --pretty=expanded) | |
let values = vec![1, 2, 3]; | |
{ | |
let result = match values.into_iter() { | |
mut iter => loop { | |
match iter.next() { | |
Some(x) => { println(x); }, | |
None => break, | |
) | |
}, | |
}; | |
result | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment