Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum List {
- // Cons: Tuple struct that wraps an element and a pointer to the next node
- Cons(u32, Box<List>),
- // Nil: A node that signifies the end of the linked list
- Nil,
- }
- fn car(l : &List) -> u32 {
- match *l {
- Nil => 420,
- Cons(n, _) => n
- }
- }
- fn cdr(l: &List) -> &List {
- match *l {
- Nil => &Nil,
- Cons(_,ref tail) => tail
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement