Skip to content

Instantly share code, notes, and snippets.

@arielb1
Created February 12, 2014 16:47
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 arielb1/8959466 to your computer and use it in GitHub Desktop.
Save arielb1/8959466 to your computer and use it in GitHub Desktop.
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