Skip to content

Commit b0abe31

Browse files
committed
Implement additional suggestions from review
(cherry picked from commit 5be552d557765a8ccc919185838067b3c77eab95)
1 parent be0a14b commit b0abe31

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,12 @@ impl core::fmt::Display for TryReserveError {
268268
impl std::error::Error for TryReserveError {}
269269

270270
// NOTE: This is copied from the slice module in the std lib.
271-
/// The error type returned by [`get_disjoint_indices_mut`][`IndexMap::get_disjoint_indices_mut`].
271+
/// The error type returned by [`get_disjoint_indices_mut`][`RingMap::get_disjoint_indices_mut`].
272272
///
273273
/// It indicates one of two possible errors:
274274
/// - An index is out-of-bounds.
275-
/// - The same index appeared multiple times in the array
276-
/// (or different but overlapping indices when ranges are provided).
275+
/// - The same index appeared multiple times in the array.
276+
// (or different but overlapping indices when ranges are provided)
277277
#[derive(Debug, Clone, PartialEq, Eq)]
278278
pub enum GetDisjointMutError {
279279
/// An index provided was out-of-bounds for the slice.

src/map.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,10 +833,9 @@ where
833833
/// let mut map = ringmap::RingMap::from([(1, 'a'), (3, 'b'), (2, 'c')]);
834834
/// assert_eq!(map.get_disjoint_mut([&2, &1]), [Some(&mut 'c'), Some(&mut 'a')]);
835835
/// ```
836-
#[allow(unsafe_code)]
837836
pub fn get_disjoint_mut<Q, const N: usize>(&mut self, keys: [&Q; N]) -> [Option<&mut V>; N]
838837
where
839-
Q: Hash + Equivalent<K> + ?Sized,
838+
Q: ?Sized + Hash + Equivalent<K>,
840839
{
841840
let indices = keys.map(|key| self.get_index_of(key));
842841
match self.as_mut_slice().get_disjoint_opt_mut(indices) {

src/map/slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ impl<K, V> Slice<K, V> {
291291
};
292292
if idx >= len {
293293
return Err(GetDisjointMutError::IndexOutOfBounds);
294-
} else if indices[i + 1..N].contains(&Some(idx)) {
294+
} else if indices[..i].contains(&Some(idx)) {
295295
return Err(GetDisjointMutError::OverlappingIndices);
296296
}
297297
}

src/map/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ fn disjoint_indices_mut_fail_duplicate() {
10971097
map.insert(1, 10);
10981098
map.insert(321, 20);
10991099
assert_eq!(
1100-
map.get_disjoint_indices_mut([1, 2, 1]),
1100+
map.get_disjoint_indices_mut([1, 0, 1]),
11011101
Err(crate::GetDisjointMutError::OverlappingIndices)
11021102
);
11031103
}

0 commit comments

Comments
 (0)