Skip to content

Instantly share code, notes, and snippets.

@quux00
Created January 9, 2014 05:07
Show Gist options
  • Save quux00/8329661 to your computer and use it in GitHub Desktop.
Save quux00/8329661 to your computer and use it in GitHub Desktop.
Simple Rust iteration example
use std::rand::{task_rng, Rng};
fn main() {
let names = ["Alice", "Bob", "Carol"];
for name in names.iter() {
let v = task_rng().shuffle(~[1,2,3]);
for num in v.iter() {
println!("{:s} says: {:d}", *name, *num);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment