Skip to content

Instantly share code, notes, and snippets.

@tioover
Created January 17, 2015 07:50
Show Gist options
  • Save tioover/4e6ec7e3b07144a13a86 to your computer and use it in GitHub Desktop.
Save tioover/4e6ec7e3b07144a13a86 to your computer and use it in GitHub Desktop.
struct List<T> {
car: T,
cdr: Option<Box<List<T>>>,
}
fn main() {
let mut a =
List {
car: 1i8,
cdr: Some(Box::new(
List {
car: 2i8,
cdr: Some(Box::new(List {car: 3i8, cdr: None})),
}
)),
}; // construction.
a.cdr = a.cdr.unwrap().cdr;
println!("{}", a.cdr.unwrap().car)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment