Skip to content

Instantly share code, notes, and snippets.

@jorendorff
Created November 25, 2015 12:01
Show Gist options
  • Select an option

  • Save jorendorff/0613103e3ba06bd2a166 to your computer and use it in GitHub Desktop.

Select an option

Save jorendorff/0613103e3ba06bd2a166 to your computer and use it in GitHub Desktop.
// Simple shared-tail singly linked list in Rust
use std::rc::Rc;
pub enum List<T> {
Nil,
Cons(Rc<(T, List<T>)>)
}
fn main() {
let empty_list: List<u32> = List::Nil;
let one_item = List::Cons(Rc::new((8675309, empty_list)));
let _two_items = List::Cons(Rc::new((112358, one_item)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment