use hashbrown::HashMap; use idbag::{ArcIdU32, IdBagU32, IdU32}; #[test] fn access() { let mut m: HashMap = HashMap::new(); let idbag = IdBagU32::new(); let id = idbag.alloc(); let idval = id.get(); m.insert(id, String::from("hello")); // Look up using &u32 if let Some(v) = m.get(&idval) { assert_eq!(v, &String::from("hello")); } else { panic!("Unable to find entry"); } } #[test] fn arced() { let mut m: HashMap = HashMap::new(); let idbag = IdBagU32::new(); let id = idbag.alloc().into_arcid(); let idval = id.val(); // Actually testing the clone here, so don't warn about it #[allow(clippy::redundant_clone)] m.insert(id.clone(), String::from("hello")); // Look up using &u32 if let Some(v) = m.get(&idval) { assert_eq!(v, &String::from("hello")); } else { panic!("Unable to find entry"); } } // vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :