Skip to content

Commit ec4a929

Browse files
committed
fix: clippy
1 parent 829f269 commit ec4a929

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ impl<T> PathTree<T> {
178178
}
179179

180180
/// Inserts a part path-value to the tree and returns the id.
181+
#[allow(clippy::missing_panics_doc)]
181182
#[must_use]
182183
pub fn insert(&mut self, path: &str, value: T) -> usize {
183184
let mut node = &mut self.node;

src/node.rs

+20-21
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,9 @@ impl<T: fmt::Debug> Node<T> {
387387
self._find(0, bytes, &mut ranges).map(|t| (t, ranges))
388388
}
389389

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

412415
if m == 0 {
413416
return self.value.take();
414-
} else {
417+
} else if let Some(id) = self.nodes0.as_mut().and_then(|nodes| {
415418
// static
416-
if let Some(id) = self.nodes0.as_mut().and_then(|nodes| {
417-
nodes
418-
.binary_search_by(|node| match &node.key {
419-
Key::String(s) => {
420-
// s[0].cmp(&bytes[0])
421-
// opt!
422-
// lets `/` at end
423-
compare(s[0], bytes[0])
424-
}
425-
Key::Parameter(_) => unreachable!(),
426-
})
427-
.ok()
428-
.and_then(|i| nodes[i]._remove(start, bytes))
429-
}) {
430-
return Some(id);
431-
}
419+
nodes
420+
.binary_search_by(|node| match &node.key {
421+
Key::String(s) => {
422+
// s[0].cmp(&bytes[0])
423+
// opt!
424+
// lets `/` at end
425+
compare(s[0], bytes[0])
426+
}
427+
Key::Parameter(_) => unreachable!(),
428+
})
429+
.ok()
430+
.and_then(|i| nodes[i]._remove(start, bytes))
431+
}) {
432+
return Some(id);
432433
}
433434

434435
// parameter
@@ -582,10 +583,8 @@ impl<T: fmt::Debug> Node<T> {
582583
return self.value.take();
583584
}
584585
} else {
585-
if self.nodes0.is_none() && self.nodes1.is_none() {
586-
if self.value.is_some() {
587-
return self.value.take();
588-
}
586+
if self.nodes0.is_none() && self.nodes1.is_none() && self.value.is_some() {
587+
return self.value.take();
589588
}
590589

591590
// static

0 commit comments

Comments
 (0)