Skip to content

Commit e52627b

Browse files
committed
test: add test for HashMap::get_mut with non-existent key
Signed-off-by: cppbear <chubei99@outlook.com>
1 parent 6263458 commit e52627b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/map.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5058,6 +5058,10 @@ mod test_map {
50585058
Some(x) => *x = new,
50595059
}
50605060
assert_eq!(m.get(&5), Some(&new));
5061+
let mut hashmap: HashMap<i32, String> = HashMap::default();
5062+
let key = &1;
5063+
let result = hashmap.get_mut(key);
5064+
assert!(result.is_none());
50615065
}
50625066

50635067
#[test]

0 commit comments

Comments
 (0)