Last active
August 29, 2015 13:57
-
-
Save eddyb/9573017 to your computer and use it in GitHub Desktop.
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
mod config { | |
pub enum Node<T> { | |
Directory(~str, ~[Node<T>]), | |
Entry(~str, T) | |
} | |
impl<T> Node<T> { | |
pub fn add(&mut self, entry: Node<T>) -> bool { | |
match *self { | |
Directory(_, ref mut list) => { list.push(entry); true } | |
_ => false | |
} | |
} | |
} | |
} | |
fn main() { | |
let mut dir = config::Directory(~"dir", ~[]); | |
dir.add(config::Entry(~"test", 0.0)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment