Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,13 @@ impl<T: fmt::Debug> Node<T> {

// parameter
if let Some(id) = self.nodes1.as_ref().and_then(|nodes| {
let b = m > 0;
nodes
.iter()
.filter(|node| match node.key {
Key::Parameter(pk)
if pk == Kind::Normal || pk == Kind::OneOrMore =>
{
b
m > 0
}
_ => true,
})
Expand Down Expand Up @@ -250,14 +249,13 @@ impl<T: fmt::Debug> Node<T> {

// parameter => `:a:b:c`
if let Some(id) = self.nodes1.as_ref().and_then(|nodes| {
let b = m - 1 > 0;
nodes
.iter()
.filter(|node| match node.key {
Key::Parameter(pk)
if pk == Kind::Normal || pk == Kind::OneOrMore =>
{
b
m - 1 > 0
}
_ => true,
})
Expand All @@ -271,14 +269,13 @@ impl<T: fmt::Debug> Node<T> {
// parameter => `:a:b?:c?`
if k == &Kind::Optional || k == &Kind::OptionalSegment {
if let Some(id) = self.nodes1.as_ref().and_then(|nodes| {
let b = m > 0;
nodes
.iter()
.filter(|node| match &node.key {
Key::Parameter(pk)
if pk == &Kind::Normal || pk == &Kind::OneOrMore =>
{
b
m > 0
}
_ => true,
})
Expand Down Expand Up @@ -341,7 +338,7 @@ impl<T: fmt::Debug> Node<T> {
if let Key::String(s) = &node.key {
let is_slash = is_one_or_more && s.len() == 1 && s[0] == b'/';
if is_slash {
let r = bytes
if let Some(id) = bytes
.iter()
.enumerate()
.filter_map(|(n, b)| (s[0] == *b).then_some(n))
Expand All @@ -358,10 +355,9 @@ impl<T: fmt::Debug> Node<T> {
})
})
})
});

if r.is_some() {
return r;
})
{
return Some(id);
}
}

Expand Down