Skip to content

Instantly share code, notes, and snippets.

@durka
Forked from anonymous/playground.rs
Last active October 8, 2015 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save durka/49b7cbec66764221b822 to your computer and use it in GitHub Desktop.
Save durka/49b7cbec66764221b822 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
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