Created
March 14, 2014 18:34
-
-
Save Kimundi/9553887 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) | |
} | |
pub fn add_entry<T>(node: &Node<T>, entry: &Node<T>) -> ::std::option::Option<&Node<T>> { | |
match node { | |
Directory(name, list) => { ::std::vec::append_one(list, entry); Some(node) } | |
_ => { None } | |
} | |
} | |
} | |
fn main() { | |
let entry = config::Entry(~"test", ~0.0); | |
let dir = config::Directory(~"dir", ~[]); | |
let dir2 = config::add_entry(dir, entry); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment