Created
March 27, 2014 08:27
-
-
Save b0urb4k1/9802899 to your computer and use it in GitHub Desktop.
config
This file contains hidden or 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
| use std::hashmap::HashMap; | |
| pub enum Value { | |
| Single(~str), | |
| Object(~[Value]), | |
| List(~[Value]) | |
| } | |
| pub struct Config { | |
| map : HashMap<~str, Value> | |
| } | |
| pub mod merge { | |
| pub struct Unite<T> { t: T } | |
| pub struct TakeLeft<T> { t: T } | |
| pub struct TakeRight<T> { t: T } | |
| pub trait Mergable<T> { | |
| fn merge(&self, other: &T); | |
| } | |
| impl Mergable<::config::Value> for Unite<::config::Value> { | |
| fn merge(&self, other: &::config::Value) { | |
| } | |
| } | |
| impl Mergable<::config::Config> for Unite<::config::Config> { | |
| fn merge(&self, other: &::config::Config) { | |
| } | |
| } | |
| impl Mergable<::config::Value> for TakeLeft<::config::Value> { | |
| fn merge(&self, other: &::config::Value) { | |
| } | |
| } | |
| impl Mergable<::config::Config> for TakeLeft<::config::Config> { | |
| fn merge(&self, other: &::config::Config) { | |
| } | |
| } | |
| impl Mergable<::config::Value> for TakeRight<::config::Value> { | |
| fn merge(&self, other: &::config::Value) { | |
| } | |
| } | |
| impl Mergable<::config::Config> for TakeRight<::config::Config> { | |
| fn merge(&self, other: &::config::Config) { | |
| } | |
| } | |
| } | |
| impl Config { | |
| pub fn new() -> Config { | |
| return Config { map: HashMap::<~str, Value>::new() } | |
| } | |
| pub fn add(&mut self, name: ~str, entry: Value) { | |
| self.map.insert(name, entry); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment