Created
January 5, 2014 17:25
-
-
Save krdln/8271065 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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