Skip to content

Commit

Permalink
box smart pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
Matrx123 committed Jun 30, 2024
1 parent 8d51b77 commit aca9505
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions exercises/19_smart_pointers/box1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<List>),
Nil,
}

use crate::List::{Cons, Nil};

fn main() {
println!("This is an empty cons list: {:?}", create_empty_list());
println!(
Expand All @@ -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)]
Expand Down

0 comments on commit aca9505

Please sign in to comment.