use iddqd::{IdHashItem, IdHashMap, id_upcast};

struct Config {
    key: String,
    value: String,
}

impl IdHashItem for Config {
    type Key<'a> = &'a str;
    fn key(&self) -> &str { &self.key }
    id_upcast!();
}

fn main() {
    let mut map = IdHashMap::<Config>::new();
    map.insert_unique(Config { key: "host".into(), value: "localhost".into() }).unwrap();
    map.insert_unique(Config { key: "port".into(), value: "8080".into() }).unwrap();

    println!("host = {}", map.get("host").unwrap().value);
    println!("port = {}", map.get("port").unwrap().value);
}