Created
November 25, 2015 12:01
-
-
Save jorendorff/0613103e3ba06bd2a166 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
| // 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