diff --git a/src/bitvec.rs b/src/bitvec.rs index 907756f..b9592a1 100644 --- a/src/bitvec.rs +++ b/src/bitvec.rs @@ -89,7 +89,7 @@ impl AdaptiveMap { // implementation is not able to see that the `self` // mutable borrow on return is only on the // early-return path. - let small_mode_idx = keys.iter().position(|k| *k == key); + let small_mode_idx = keys.iter().take(len as usize).position(|k| *k == key); let needs_expand = small_mode_idx.is_none() && len == SMALL_ELEMS as u32; (needs_expand, small_mode_idx) }