Created
February 12, 2014 16:47
-
-
Save arielb1/8959466 to your computer and use it in GitHub Desktop.
This file contains 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
struct stack<'a> { | |
next: Option<&'a stack<'a>>, | |
data: i32 | |
} | |
fn main() -> () { | |
let a = stack { data: 0, next: None }; | |
let b = stack { data: 1, next: Some(&a) }; | |
let c = stack { data: 2, next: Some(&b) }; | |
let mut cur = c; | |
loop match cur { | |
None => break; | |
Some(u) => { | |
println(u.data); | |
cur = u.next; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment