From abc1c648568a45e5c4c0f96bce7c1d9dc2dc3011 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Wed, 4 Dec 2024 21:36:42 +0000 Subject: [PATCH] Fixed new clippy lints. --- src/list/mod.rs | 4 ++-- src/list/test.rs | 4 +++- src/map/hash_trie_map/mod.rs | 6 +++--- src/map/red_black_tree_map/mod.rs | 16 ++++++++-------- src/queue/mod.rs | 4 ++-- src/vector/mod.rs | 2 +- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/list/mod.rs b/src/list/mod.rs index 7cf048c..da148c8 100644 --- a/src/list/mod.rs +++ b/src/list/mod.rs @@ -435,7 +435,7 @@ where length: usize, } -impl<'a, T, P> IterPtr<'a, T, P> +impl IterPtr<'_, T, P> where P: SharedPointerKind, { @@ -466,7 +466,7 @@ where } } -impl<'a, T, P> ExactSizeIterator for IterPtr<'a, T, P> where P: SharedPointerKind {} +impl ExactSizeIterator for IterPtr<'_, T, P> where P: SharedPointerKind {} #[cfg(feature = "serde")] pub mod serde { diff --git a/src/list/test.rs b/src/list/test.rs index 61aea30..5405bf3 100644 --- a/src/list/test.rs +++ b/src/list/test.rs @@ -336,8 +336,10 @@ fn test_clone() { fn test_drop_list() { // When it is dropped, it will set the variable it owned to false. use core::cell::Cell; + struct DropStruct<'a>(&'a Cell); - impl<'a> Drop for DropStruct<'a> { + + impl Drop for DropStruct<'_> { fn drop(&mut self) { self.0.set(false); } diff --git a/src/map/hash_trie_map/mod.rs b/src/map/hash_trie_map/mod.rs index b03e323..0e531b3 100644 --- a/src/map/hash_trie_map/mod.rs +++ b/src/map/hash_trie_map/mod.rs @@ -913,7 +913,7 @@ where } } -impl<'a, K, Q: ?Sized, V, P, H: BuildHasher> Index<&'a Q> for HashTrieMap +impl Index<&Q> for HashTrieMap where K: Eq + Hash + Borrow, Q: Hash + Eq, @@ -1101,7 +1101,7 @@ mod iter_utils { } } -impl<'a, K, V, P> IterPtr<'a, K, V, P> +impl IterPtr<'_, K, V, P> where K: Eq + Hash, P: SharedPointerKind, @@ -1149,7 +1149,7 @@ where } } -impl<'a, K: Eq + Hash, V, P> ExactSizeIterator for IterPtr<'a, K, V, P> where P: SharedPointerKind {} +impl ExactSizeIterator for IterPtr<'_, K, V, P> where P: SharedPointerKind {} #[cfg(feature = "serde")] pub mod serde { diff --git a/src/map/red_black_tree_map/mod.rs b/src/map/red_black_tree_map/mod.rs index 7092192..fce758f 100644 --- a/src/map/red_black_tree_map/mod.rs +++ b/src/map/red_black_tree_map/mod.rs @@ -159,8 +159,8 @@ where Node { entry: SharedPointer::new(entry), color: Color::Black, left: None, right: None } } - fn borrow(node: &Option, P>>) -> Option<&Node> { - node.as_ref().map(Borrow::borrow) + fn borrow(node: Option<&SharedPointer, P>>) -> Option<&Node> { + node.map(Borrow::borrow) } fn left_color(&self) -> Option { @@ -990,7 +990,7 @@ where } } -impl<'a, K, Q: ?Sized, V, P> Index<&'a Q> for RedBlackTreeMap +impl Index<&Q> for RedBlackTreeMap where K: Ord + Borrow, Q: Ord, @@ -1227,7 +1227,7 @@ mod iter_utils { Q: Ord + ?Sized, { let child = self.stack.last().and_then(|node| { - let c = if self.backwards { &node.right } else { &node.left }; + let c = if self.backwards { node.right.as_ref() } else { node.left.as_ref() }; Node::borrow(c) }); @@ -1284,7 +1284,7 @@ mod iter_utils { Q: Ord + ?Sized, { if let Some(node) = self.stack.pop() { - let child = if self.backwards { &node.left } else { &node.right }; + let child = if self.backwards { node.left.as_ref() } else { node.right.as_ref() }; if let Some(c) = Node::borrow(child) { self.stack.push(c); @@ -1324,7 +1324,7 @@ where size: usize, } -impl<'a, K, V, P> IterPtr<'a, K, V, P> +impl IterPtr<'_, K, V, P> where K: Ord, P: SharedPointerKind, @@ -1370,7 +1370,7 @@ where } } -impl<'a, K: Ord, V, P> ExactSizeIterator for IterPtr<'a, K, V, P> where P: SharedPointerKind {} +impl ExactSizeIterator for IterPtr<'_, K, V, P> where P: SharedPointerKind {} #[derive(Debug)] pub struct RangeIterPtr<'a, K, V, RB, Q: ?Sized, P> @@ -1393,7 +1393,7 @@ where RB: RangeBounds, P: SharedPointerKind, { - fn new(map: &'a RedBlackTreeMap, range: RB) -> RangeIterPtr<'_, K, V, RB, Q, P> { + fn new(map: &'a RedBlackTreeMap, range: RB) -> RangeIterPtr<'a, K, V, RB, Q, P> { RangeIterPtr { map, stack_forward: None, stack_backward: None, range, _q: PhantomData } } diff --git a/src/queue/mod.rs b/src/queue/mod.rs index 2531856..aeabab8 100644 --- a/src/queue/mod.rs +++ b/src/queue/mod.rs @@ -316,7 +316,7 @@ where Initialized { vec: Vec<&'a SharedPointer>, current: Option }, } -impl<'a, T, P> LazilyReversedListIter<'a, T, P> +impl LazilyReversedListIter<'_, T, P> where P: SharedPointerKind, { @@ -374,7 +374,7 @@ where } } -impl<'a, T, P> ExactSizeIterator for LazilyReversedListIter<'a, T, P> where P: SharedPointerKind {} +impl ExactSizeIterator for LazilyReversedListIter<'_, T, P> where P: SharedPointerKind {} #[cfg(feature = "serde")] pub mod serde { diff --git a/src/vector/mod.rs b/src/vector/mod.rs index f3111fe..ccba9cb 100644 --- a/src/vector/mod.rs +++ b/src/vector/mod.rs @@ -864,7 +864,7 @@ where } } -impl<'a, T, P> ExactSizeIterator for IterPtr<'a, T, P> where P: SharedPointerKind {} +impl ExactSizeIterator for IterPtr<'_, T, P> where P: SharedPointerKind {} #[cfg(feature = "serde")] pub mod serde {