This commit is contained in:
2025-03-26 12:41:58 -04:00
parent 637b26a0e9
commit 416dd617e6
36 changed files with 732 additions and 0 deletions

1
example_4/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target

6
example_4/Cargo.toml Normal file
View File

@@ -0,0 +1,6 @@
[package]
name = "example_4"
version = "0.1.0"
edition = "2021"
[dependencies]

15
example_4/src/main.rs Normal file
View File

@@ -0,0 +1,15 @@
#[derive(Debug)]
enum Tree<T> {
Empty,
Node(T, Box<Tree<T>>, Box<Tree<T>>),
}
fn main() {
let tree = Tree::Node(
42,
Box::new(Tree::Node(0, Box::new(Tree::Empty), Box::new(Tree::Empty))),
Box::new(Tree::Empty),
);
println!("{:?}", tree); // prints Node(42, Node(0, Empty, Empty), Empty)
}