Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. use crate::List::{Cons, Nil};
  2.  
  3. fn main() {
  4. let the_list = Cons(1, Box::new(Cons(2, Box::new(Cons(3, Box::new(Nil))))));
  5. println!("{:?}", the_list);
  6.  
  7. let mut list = the_list;
  8. while let Cons(n, l) = list {
  9. println!("{}", n);
  10. list = *l;
  11. }
  12. }
  13.  
  14. #[derive(Debug)]
  15. enum List<T> {
  16. Cons(T, Box<List<T>>),
  17. Nil,
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement