Skip to content

Instantly share code, notes, and snippets.

Last active Dec 16, 2015
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));
println(fmt!("Closurey loop %d", *var));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment