Skip to content

Commit

Permalink
fn signature: move_at(K) -> move_at(&K)
Browse files Browse the repository at this point in the history
  • Loading branch information
olebedev committed Feb 29, 2024
1 parent 41d96a0 commit 2b45428
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/linked_hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1817,16 +1817,16 @@ impl<'a, K, V, S> CursorMut<'a, K, V, S> {
/// if the element exists and the operation succeeds, or `false` if the element does not
/// exist.
#[inline]
pub fn move_at(&mut self, key: K) -> bool
pub fn move_at(&mut self, key: &K) -> bool
where
K: Eq + Hash,
S: BuildHasher,
{
unsafe {
let hash = hash_key(self.hash_builder, &key);
let hash = hash_key(self.hash_builder, key);
let i_entry = self
.table
.find_entry(hash, |o| (*o).as_ref().key_ref().eq(&key));
.find_entry(hash, |o| (*o).as_ref().key_ref().eq(key));

match i_entry {
Ok(occupied) => {
Expand Down
4 changes: 2 additions & 2 deletions tests/linked_hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,12 +661,12 @@ fn test_cursor_mut_move_at() {

if let linked_hash_map::Entry::Occupied(entry) = map.entry(3) {
let mut cursor = entry.cursor_mut();
let moved = cursor.move_at(6);
let moved = cursor.move_at(&6);
assert!(moved);
let value = cursor.current();
assert!(value.is_some());
assert_eq!(value.unwrap().1, &mut 6);
let moved = cursor.move_at(7);
let moved = cursor.move_at(&7);
assert!(!moved);
}
}
Expand Down

0 comments on commit 2b45428

Please sign in to comment.