Skip to content

Commit

Permalink
fix: Remove unnecessary explicit lifetimes (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
DataTriny authored Dec 8, 2024
1 parent f2c694b commit d2bcd6d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 34 deletions.
42 changes: 18 additions & 24 deletions consumer/src/iterators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self::Item> {
Expand Down Expand Up @@ -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<Self::Item> {
if self.done {
None
Expand All @@ -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.
///
Expand Down Expand Up @@ -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<Self::Item> {
Expand Down Expand Up @@ -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<Self::Item> {
if self.done {
None
Expand All @@ -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<Node<'a>>,
Expand Down Expand Up @@ -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<Filter: Fn(&Node) -> FilterResult> DoubleEndedIterator
for FollowingFilteredSiblings<'_, Filter>
{
fn next_back(&mut self) -> Option<Self::Item> {
if self.done {
Expand All @@ -312,10 +312,7 @@ impl<'a, Filter: Fn(&Node) -> FilterResult> DoubleEndedIterator
}
}

impl<'a, Filter: Fn(&Node) -> FilterResult> FusedIterator
for FollowingFilteredSiblings<'a, Filter>
{
}
impl<Filter: Fn(&Node) -> FilterResult> FusedIterator for FollowingFilteredSiblings<'_, Filter> {}

/// An iterator that yields preceding siblings of a node according to the
/// specified filter.
Expand Down Expand Up @@ -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<Filter: Fn(&Node) -> FilterResult> DoubleEndedIterator
for PrecedingFilteredSiblings<'_, Filter>
{
fn next_back(&mut self) -> Option<Self::Item> {
if self.done {
Expand All @@ -373,10 +370,7 @@ impl<'a, Filter: Fn(&Node) -> FilterResult> DoubleEndedIterator
}
}

impl<'a, Filter: Fn(&Node) -> FilterResult> FusedIterator
for PrecedingFilteredSiblings<'a, Filter>
{
}
impl<Filter: Fn(&Node) -> FilterResult> FusedIterator for PrecedingFilteredSiblings<'_, Filter> {}

/// An iterator that yields children of a node according to the specified
/// filter.
Expand Down Expand Up @@ -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<Filter: Fn(&Node) -> FilterResult> DoubleEndedIterator for FilteredChildren<'_, Filter> {
fn next_back(&mut self) -> Option<Self::Item> {
if self.done {
None
Expand All @@ -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<Filter: Fn(&Node) -> FilterResult> FusedIterator for FilteredChildren<'_, Filter> {}

pub(crate) enum LabelledBy<'a, Filter: Fn(&Node) -> FilterResult> {
FromDescendants(FilteredChildren<'a, Filter>),
Expand Down Expand Up @@ -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<Filter: Fn(&Node) -> FilterResult> DoubleEndedIterator for LabelledBy<'_, Filter> {
fn next_back(&mut self) -> Option<Self::Item> {
match self {
Self::FromDescendants(iter) => iter.next_back(),
Expand All @@ -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<Filter: Fn(&Node) -> FilterResult> FusedIterator for LabelledBy<'_, Filter> {}

#[cfg(test)]
mod tests {
Expand Down
14 changes: 7 additions & 7 deletions consumer/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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<Ordering> {
if self.root_node.id() != other.root_node.id() {
return None;
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion platforms/atspi-common/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
if self.0.label_comes_from_value() {
self.0.value()
Expand Down
2 changes: 1 addition & 1 deletion platforms/macos/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion platforms/windows/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d2bcd6d

Please sign in to comment.