Skip to content

Instantly share code, notes, and snippets.

@eddyb
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eddyb/9573017 to your computer and use it in GitHub Desktop.
Save eddyb/9573017 to your computer and use it in GitHub Desktop.
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