Skip to content

Instantly share code, notes, and snippets.

@kgaughan
Created April 21, 2014 14:06
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 kgaughan/11143755 to your computer and use it in GitHub Desktop.
Save kgaughan/11143755 to your computer and use it in GitHub Desktop.
Experiment with unique pointers, pattern matching, union types, closures, and tasks.
enum List {
Cons(u32, ~List),
Nil,
}
fn main() {
let list = Cons(1, ~Cons(2, ~Cons(3, ~Nil)));
let mut head = ~list;
loop {
match head {
~Nil => break,
~Cons(x, next_head) => {
println!("{}", x);
head = next_head
}
}
}
for i in range(0, 5) {
spawn(proc() {
println!("Here's some Rust! {}", i);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment