Skip to content

Instantly share code, notes, and snippets.

@krdln
Created January 5, 2014 17:25
Show Gist options
  • Save krdln/8271065 to your computer and use it in GitHub Desktop.
Save krdln/8271065 to your computer and use it in GitHub Desktop.
enum List {
Cons(int, ~List),
Nil
}
impl List {
fn prepend(~self, x : int) -> ~List {
~Cons(x, self)
}
}
fn main() {
let mut li = ~Cons(2, ~Nil);
li = li.prepend(1);
println!("{:?}", li);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment