Skip to content

Commit

Permalink
fix: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Jan 15, 2024
1 parent 829f269 commit ec4a929
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ impl<T> PathTree<T> {
}

/// Inserts a part path-value to the tree and returns the id.
#[allow(clippy::missing_panics_doc)]
#[must_use]
pub fn insert(&mut self, path: &str, value: T) -> usize {
let mut node = &mut self.node;
Expand Down
41 changes: 20 additions & 21 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ impl<T: fmt::Debug> Node<T> {
self._find(0, bytes, &mut ranges).map(|t| (t, ranges))
}

#[allow(clippy::only_used_in_recursion)]
#[allow(clippy::too_many_lines)]
#[inline]
pub fn _remove(&mut self, mut start: usize, mut bytes: &[u8]) -> Option<T> {
let mut m = bytes.len();
match &self.key {
Expand All @@ -411,24 +414,22 @@ impl<T: fmt::Debug> Node<T> {

if m == 0 {
return self.value.take();
} else {
} else if let Some(id) = self.nodes0.as_mut().and_then(|nodes| {
// static
if let Some(id) = self.nodes0.as_mut().and_then(|nodes| {
nodes
.binary_search_by(|node| match &node.key {
Key::String(s) => {
// s[0].cmp(&bytes[0])
// opt!
// lets `/` at end
compare(s[0], bytes[0])
}
Key::Parameter(_) => unreachable!(),
})
.ok()
.and_then(|i| nodes[i]._remove(start, bytes))
}) {
return Some(id);
}
nodes
.binary_search_by(|node| match &node.key {
Key::String(s) => {
// s[0].cmp(&bytes[0])
// opt!
// lets `/` at end
compare(s[0], bytes[0])
}
Key::Parameter(_) => unreachable!(),
})
.ok()
.and_then(|i| nodes[i]._remove(start, bytes))
}) {
return Some(id);
}

// parameter
Expand Down Expand Up @@ -582,10 +583,8 @@ impl<T: fmt::Debug> Node<T> {
return self.value.take();
}
} else {
if self.nodes0.is_none() && self.nodes1.is_none() {
if self.value.is_some() {
return self.value.take();
}
if self.nodes0.is_none() && self.nodes1.is_none() && self.value.is_some() {
return self.value.take();
}

// static
Expand Down

0 comments on commit ec4a929

Please sign in to comment.