Skip to content

Instantly share code, notes, and snippets.

@grahamking grahamking/loop.rs
Last active Dec 16, 2015

Embed
What would you like to do?
Rust: Loop three ways
fn main() {
for 2.times {
println("Basic loop sugar")
}
2.times(||{ println("Basic loop closure"); true });
for [1,2,3].each |var| {
println(fmt!("Sugary loop %d", *var));
}
[1,2,3].each(|var|{
println(fmt!("Closurey loop %d", *var));
true
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.