diff --git a/exercises/19_smart_pointers/box1.rs b/exercises/19_smart_pointers/box1.rs index 513e7da..65aaf99 100644 --- a/exercises/19_smart_pointers/box1.rs +++ b/exercises/19_smart_pointers/box1.rs @@ -18,14 +18,16 @@ // // Execute `rustlings hint box1` or use the `hint` watch subcommand for a hint. -// I AM NOT DONE #[derive(PartialEq, Debug)] + pub enum List { - Cons(i32, List), + Cons(i32, Box), Nil, } +use crate::List::{Cons, Nil}; + fn main() { println!("This is an empty cons list: {:?}", create_empty_list()); println!( @@ -35,11 +37,11 @@ fn main() { } pub fn create_empty_list() -> List { - todo!() + Nil } pub fn create_non_empty_list() -> List { - todo!() + Cons(1, Box::new(Cons(2, Box::new(Cons(3, Box::new(Nil)))))) } #[cfg(test)]