Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Dec 25, 2024
1 parent 6deb16c commit 5c10696
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl<T> PathTree<T> {

/// Returns the [`Path`] by the given path.
#[must_use]
pub fn find<'a, 'b>(&'a self, path: &'b str) -> Option<(&T, Path<'a, 'b>)> {
pub fn find<'a, 'b>(&'a self, path: &'b str) -> Option<(&'a T, Path<'a, 'b>)> {
let bytes = path.as_bytes();
self.node.find(bytes).and_then(|(id, ranges)| {
self.routes.get(*id).map(|(value, pieces)| {
Expand Down Expand Up @@ -281,7 +281,7 @@ pub struct Path<'a, 'b> {
pub raws: SmallVec<[&'b str; 4]>,
}

impl<'a, 'b> Path<'a, 'b> {
impl Path<'_, '_> {
/// Gets current path pattern.
///
/// # Panics
Expand Down
22 changes: 10 additions & 12 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,8 @@ impl<T: fmt::Debug> Node<T> {

// last
if self.nodes0.is_none() && self.nodes1.is_none() {
return self.value.as_ref().map(|id| {
return self.value.as_ref().inspect(|_| {
ranges.push(start..start);
id
});
}
} else {
Expand All @@ -231,10 +230,11 @@ impl<T: fmt::Debug> Node<T> {
.enumerate()
.filter_map(|(n, b)| (s[0] == *b).then_some(n))
.find_map(|n| {
node._find(start + n, &bytes[n..], ranges).map(|id| {
ranges.push(start..start + n);
id
})
node._find(start + n, &bytes[n..], ranges).inspect(
|_| {
ranges.push(start..start + n);
},
)
})
}
Key::Parameter(_) => unreachable!(),
Expand Down Expand Up @@ -318,9 +318,8 @@ impl<T: fmt::Debug> Node<T> {
}

if self.nodes0.is_none() && self.nodes1.is_none() {
return self.value.as_ref().map(|id| {
return self.value.as_ref().inspect(|_| {
ranges.push(start..start);
id
});
}
} else {
Expand All @@ -346,10 +345,9 @@ impl<T: fmt::Debug> Node<T> {
.enumerate()
.filter_map(|(n, b)| (s[0] == *b).then_some(n))
.find_map(|n| {
node._find(start + n, &bytes[n..], ranges).map(
|id| {
node._find(start + n, &bytes[n..], ranges).inspect(
|_| {
ranges.push(start..start + n);
id
},
)
});
Expand Down Expand Up @@ -385,7 +383,7 @@ impl<T: fmt::Debug> Node<T> {

pub fn find(&self, bytes: &[u8]) -> Option<(&T, SmallVec<[Range<usize>; 8]>)> {
let mut ranges = SmallVec::<[Range<usize>; 8]>::new_const(); // opt!
return self._find(0, bytes, &mut ranges).map(|t| (t, ranges));
self._find(0, bytes, &mut ranges).map(|t| (t, ranges))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl<'a> Parser<'a> {
}
}

impl<'a> Iterator for Parser<'a> {
impl Iterator for Parser<'_> {
type Item = Piece;

fn next(&mut self) -> Option<Self::Item> {
Expand Down

0 comments on commit 5c10696

Please sign in to comment.