From 2b45428b52b43602279eb9a74e9b714aee2f6218 Mon Sep 17 00:00:00 2001 From: Oleg Lebedev Date: Thu, 29 Feb 2024 20:38:34 +1100 Subject: [PATCH] fn signature: move_at(K) -> move_at(&K) --- src/linked_hash_map.rs | 6 +++--- tests/linked_hash_map.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/linked_hash_map.rs b/src/linked_hash_map.rs index 33a8ee4..ade309a 100644 --- a/src/linked_hash_map.rs +++ b/src/linked_hash_map.rs @@ -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) => { diff --git a/tests/linked_hash_map.rs b/tests/linked_hash_map.rs index 850cd84..3e44019 100644 --- a/tests/linked_hash_map.rs +++ b/tests/linked_hash_map.rs @@ -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); } }