From d2bcd6d3048d23df4e132bee6171eb247b2dc2c8 Mon Sep 17 00:00:00 2001 From: Arnold Loubriat Date: Sun, 8 Dec 2024 13:20:47 +0100 Subject: [PATCH] fix: Remove unnecessary explicit lifetimes (#488) --- consumer/src/iterators.rs | 42 +++++++++++++----------------- consumer/src/text.rs | 14 +++++----- platforms/atspi-common/src/node.rs | 2 +- platforms/macos/src/node.rs | 2 +- platforms/windows/src/node.rs | 2 +- 5 files changed, 28 insertions(+), 34 deletions(-) diff --git a/consumer/src/iterators.rs b/consumer/src/iterators.rs index efef7ab8..b0164fb1 100644 --- a/consumer/src/iterators.rs +++ b/consumer/src/iterators.rs @@ -48,7 +48,7 @@ impl<'a> FollowingSiblings<'a> { } } -impl<'a> Iterator for FollowingSiblings<'a> { +impl Iterator for FollowingSiblings<'_> { type Item = NodeId; fn next(&mut self) -> Option { @@ -76,7 +76,7 @@ impl<'a> Iterator for FollowingSiblings<'a> { } } -impl<'a> DoubleEndedIterator for FollowingSiblings<'a> { +impl DoubleEndedIterator for FollowingSiblings<'_> { fn next_back(&mut self) -> Option { if self.done { None @@ -94,9 +94,9 @@ impl<'a> DoubleEndedIterator for FollowingSiblings<'a> { } } -impl<'a> ExactSizeIterator for FollowingSiblings<'a> {} +impl ExactSizeIterator for FollowingSiblings<'_> {} -impl<'a> FusedIterator for FollowingSiblings<'a> {} +impl FusedIterator for FollowingSiblings<'_> {} /// An iterator that yields preceding siblings of a node. /// @@ -126,7 +126,7 @@ impl<'a> PrecedingSiblings<'a> { } } -impl<'a> Iterator for PrecedingSiblings<'a> { +impl Iterator for PrecedingSiblings<'_> { type Item = NodeId; fn next(&mut self) -> Option { @@ -156,7 +156,7 @@ impl<'a> Iterator for PrecedingSiblings<'a> { } } -impl<'a> DoubleEndedIterator for PrecedingSiblings<'a> { +impl DoubleEndedIterator for PrecedingSiblings<'_> { fn next_back(&mut self) -> Option { if self.done { None @@ -174,9 +174,9 @@ impl<'a> DoubleEndedIterator for PrecedingSiblings<'a> { } } -impl<'a> ExactSizeIterator for PrecedingSiblings<'a> {} +impl ExactSizeIterator for PrecedingSiblings<'_> {} -impl<'a> FusedIterator for PrecedingSiblings<'a> {} +impl FusedIterator for PrecedingSiblings<'_> {} fn next_filtered_sibling<'a>( node: Option>, @@ -297,8 +297,8 @@ impl<'a, Filter: Fn(&Node) -> FilterResult> Iterator for FollowingFilteredSiblin } } -impl<'a, Filter: Fn(&Node) -> FilterResult> DoubleEndedIterator - for FollowingFilteredSiblings<'a, Filter> +impl FilterResult> DoubleEndedIterator + for FollowingFilteredSiblings<'_, Filter> { fn next_back(&mut self) -> Option { if self.done { @@ -312,10 +312,7 @@ impl<'a, Filter: Fn(&Node) -> FilterResult> DoubleEndedIterator } } -impl<'a, Filter: Fn(&Node) -> FilterResult> FusedIterator - for FollowingFilteredSiblings<'a, Filter> -{ -} +impl FilterResult> FusedIterator for FollowingFilteredSiblings<'_, Filter> {} /// An iterator that yields preceding siblings of a node according to the /// specified filter. @@ -358,8 +355,8 @@ impl<'a, Filter: Fn(&Node) -> FilterResult> Iterator for PrecedingFilteredSiblin } } -impl<'a, Filter: Fn(&Node) -> FilterResult> DoubleEndedIterator - for PrecedingFilteredSiblings<'a, Filter> +impl FilterResult> DoubleEndedIterator + for PrecedingFilteredSiblings<'_, Filter> { fn next_back(&mut self) -> Option { if self.done { @@ -373,10 +370,7 @@ impl<'a, Filter: Fn(&Node) -> FilterResult> DoubleEndedIterator } } -impl<'a, Filter: Fn(&Node) -> FilterResult> FusedIterator - for PrecedingFilteredSiblings<'a, Filter> -{ -} +impl FilterResult> FusedIterator for PrecedingFilteredSiblings<'_, Filter> {} /// An iterator that yields children of a node according to the specified /// filter. @@ -417,7 +411,7 @@ impl<'a, Filter: Fn(&Node) -> FilterResult> Iterator for FilteredChildren<'a, Fi } } -impl<'a, Filter: Fn(&Node) -> FilterResult> DoubleEndedIterator for FilteredChildren<'a, Filter> { +impl FilterResult> DoubleEndedIterator for FilteredChildren<'_, Filter> { fn next_back(&mut self) -> Option { if self.done { None @@ -430,7 +424,7 @@ impl<'a, Filter: Fn(&Node) -> FilterResult> DoubleEndedIterator for FilteredChil } } -impl<'a, Filter: Fn(&Node) -> FilterResult> FusedIterator for FilteredChildren<'a, Filter> {} +impl FilterResult> FusedIterator for FilteredChildren<'_, Filter> {} pub(crate) enum LabelledBy<'a, Filter: Fn(&Node) -> FilterResult> { FromDescendants(FilteredChildren<'a, Filter>), @@ -460,7 +454,7 @@ impl<'a, Filter: Fn(&Node) -> FilterResult> Iterator for LabelledBy<'a, Filter> } } -impl<'a, Filter: Fn(&Node) -> FilterResult> DoubleEndedIterator for LabelledBy<'a, Filter> { +impl FilterResult> DoubleEndedIterator for LabelledBy<'_, Filter> { fn next_back(&mut self) -> Option { match self { Self::FromDescendants(iter) => iter.next_back(), @@ -471,7 +465,7 @@ impl<'a, Filter: Fn(&Node) -> FilterResult> DoubleEndedIterator for LabelledBy<' } } -impl<'a, Filter: Fn(&Node) -> FilterResult> FusedIterator for LabelledBy<'a, Filter> {} +impl FilterResult> FusedIterator for LabelledBy<'_, Filter> {} #[cfg(test)] mod tests { diff --git a/consumer/src/text.rs b/consumer/src/text.rs index 0404ad0a..b8ba6a03 100644 --- a/consumer/src/text.rs +++ b/consumer/src/text.rs @@ -177,13 +177,13 @@ impl<'a> InnerPosition<'a> { } } -impl<'a> PartialEq for InnerPosition<'a> { +impl PartialEq for InnerPosition<'_> { fn eq(&self, other: &Self) -> bool { self.node.id() == other.node.id() && self.character_index == other.character_index } } -impl<'a> Eq for InnerPosition<'a> {} +impl Eq for InnerPosition<'_> {} #[derive(Clone, Copy)] pub struct Position<'a> { @@ -455,15 +455,15 @@ impl<'a> Position<'a> { } } -impl<'a> PartialEq for Position<'a> { +impl PartialEq for Position<'_> { fn eq(&self, other: &Self) -> bool { self.root_node.id() == other.root_node.id() && self.inner == other.inner } } -impl<'a> Eq for Position<'a> {} +impl Eq for Position<'_> {} -impl<'a> PartialOrd for Position<'a> { +impl PartialOrd for Position<'_> { fn partial_cmp(&self, other: &Self) -> Option { if self.root_node.id() != other.root_node.id() { return None; @@ -742,13 +742,13 @@ impl<'a> Range<'a> { } } -impl<'a> PartialEq for Range<'a> { +impl PartialEq for Range<'_> { fn eq(&self, other: &Self) -> bool { self.node.id() == other.node.id() && self.start == other.start && self.end == other.end } } -impl<'a> Eq for Range<'a> {} +impl Eq for Range<'_> {} #[derive(Clone, Debug, PartialEq, Eq)] pub struct WeakRange { diff --git a/platforms/atspi-common/src/node.rs b/platforms/atspi-common/src/node.rs index 31518708..6948f974 100644 --- a/platforms/atspi-common/src/node.rs +++ b/platforms/atspi-common/src/node.rs @@ -34,7 +34,7 @@ use crate::{ pub(crate) struct NodeWrapper<'a>(pub(crate) &'a Node<'a>); -impl<'a> NodeWrapper<'a> { +impl NodeWrapper<'_> { pub(crate) fn name(&self) -> Option { if self.0.label_comes_from_value() { self.0.value() diff --git a/platforms/macos/src/node.rs b/platforms/macos/src/node.rs index 631e63df..6fb2a7e9 100644 --- a/platforms/macos/src/node.rs +++ b/platforms/macos/src/node.rs @@ -298,7 +298,7 @@ pub(crate) enum Value { pub(crate) struct NodeWrapper<'a>(pub(crate) &'a Node<'a>); -impl<'a> NodeWrapper<'a> { +impl NodeWrapper<'_> { fn is_root(&self) -> bool { self.0.is_root() } diff --git a/platforms/windows/src/node.rs b/platforms/windows/src/node.rs index 7a44e7c1..bc6c2933 100644 --- a/platforms/windows/src/node.rs +++ b/platforms/windows/src/node.rs @@ -43,7 +43,7 @@ fn runtime_id_from_node_id(id: NodeId) -> [i32; RUNTIME_ID_SIZE] { pub(crate) struct NodeWrapper<'a>(pub(crate) &'a Node<'a>); -impl<'a> NodeWrapper<'a> { +impl NodeWrapper<'_> { fn control_type(&self) -> UIA_CONTROLTYPE_ID { let role = self.0.role(); // TODO: Handle special cases. (#14)