extern crate trie; use trie::Trie; macro_rules! def_test { ($name:ident, $code:expr) => { #[inline(always)] fn do_test_wrap(func: T) where T: FnOnce() -> Result<(), Box<::std::error::Error>> { func().expect("unexpected error"); } #[test] fn $name() { do_test_wrap(|| { $code; Ok(()) }); } }; } def_test! { test_insert_2, { let mut tree = Trie::new(); tree.add("apple", 1); tree.add("banana", 2); tree.add("apricot", 3); assert_eq!(tree.get("apple"), Some(&1)); assert_eq!(tree.get("banana"), Some(&2)); assert_eq!(tree.get("apricot"), Some(&3)); assert_eq!(tree.get("not there"), None); assert_eq!(tree.add("apple", 4), Some(1)); assert_eq!(tree.get("apple"), Some(&4)); }}