summaryrefslogtreecommitdiff
path: root/examples/misc/src/hashmap.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/misc/src/hashmap.rs')
-rw-r--r--examples/misc/src/hashmap.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/examples/misc/src/hashmap.rs b/examples/misc/src/hashmap.rs
index 98e3f7d8..47a1b150 100644
--- a/examples/misc/src/hashmap.rs
+++ b/examples/misc/src/hashmap.rs
@@ -166,3 +166,18 @@ impl<T> HashMap<T> {
HashMap::remove_from_list(key, self.slots.get_mut(hash_mod).unwrap())
}
}
+
+#[test]
+fn test1() {
+ let mut hm: HashMap<u64> = HashMap::new();
+ hm.insert(0, 42);
+ hm.insert(128, 18);
+ hm.insert(1024, 138);
+ assert!(*hm.get(&128).unwrap() == 18);
+ let x = hm.get_mut(&1024).unwrap();
+ *x = 56;
+ assert!(*hm.get(&1024).unwrap() == 56);
+ assert!(hm.get(&10).is_none());
+ let x = hm.remove(&1024).unwrap();
+ assert!(x == 56);
+}