Skip to content

Commit 5795fe3

Browse files
committed
fix comment and add test for many_index oob
1 parent 72f0146 commit 5795fe3

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/map.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,6 @@ impl<K, V, S> IndexMap<K, V, S> {
832832
indices: [usize; N],
833833
) -> Option<[(&K, &mut V); N]> {
834834
// SAFETY: Can't allow duplicate indices as we would return several mutable refs to the same data.
835-
// Additionally, handle out-of-bounds indices (internal error in get_index_of) with panic.
836835
let len = self.len();
837836
for i in 0..N {
838837
let idx = indices[i];

src/map/tests.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,3 +479,11 @@ fn many_mut_multi_fail_duplicate() {
479479
None
480480
);
481481
}
482+
483+
#[test]
484+
fn many_index_mut_fail_oob() {
485+
let mut map: IndexMap<u32, u32> = IndexMap::default();
486+
map.insert(1, 10);
487+
map.insert(321, 20);
488+
assert_eq!(map.get_many_index_mut([1, 3]), None);
489+
}

0 commit comments

Comments
 (0)