Skip to content

Instantly share code, notes, and snippets.

@b0urb4k1
Created March 27, 2014 08:27
Show Gist options
  • Select an option

  • Save b0urb4k1/9802899 to your computer and use it in GitHub Desktop.

Select an option

Save b0urb4k1/9802899 to your computer and use it in GitHub Desktop.
config
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