Skip to content

Instantly share code, notes, and snippets.

@JohnMurray
Created January 29, 2014 12:39
Show Gist options
  • Save JohnMurray/8687063 to your computer and use it in GitHub Desktop.
Save JohnMurray/8687063 to your computer and use it in GitHub Desktop.
Simple linked-list struct in Rust that doesn't work.
struct Node<T> {
value: T,
next: Option<~Node<T>>
}
struct LinkedList<T> {
head: ~Node<T>,
tail: ~Node<T>
}
impl<T> LinkedList<T> {
fn new(item: T) -> LinkedList<T> {
let node = ~Node { value: item, next: None };
LinkedList { head: node, tail: node }
}
}
fn main() {
let n: LinkedList<~str> = LinkedList::new(~"hey there");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment