Created
November 1, 2015 22:21
-
-
Save psyomn/c08d4fae2c1e58199daa to your computer and use it in GitHub Desktop.
Recursive trees in Rust!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! Recursive enumerable types! Freaking cool! | |
#[derive(Debug)] | |
pub enum BinTree<T> { | |
Value(T, | |
Option<Box<BinTree<T>>>, | |
Option<Box<BinTree<T>>>), | |
} | |
fn main() -> () { | |
let tree: BinTree<u32> = | |
BinTree::Value(1, | |
Some(Box::new(BinTree::Value(2, None, None))), | |
Some( | |
Box::new(BinTree::Value(3, | |
Some(Box::new(BinTree::Value(4, None, None))), None)), | |
), | |
); | |
println!("{:#?}", tree); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment