SHARE
TWEET

Untitled

a guest Sep 20th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top