Idiomatic impl of unordered_begin.
This commit is contained in:
@@ -302,13 +302,11 @@ impl<'a> State<'a> {
|
|||||||
// Get the beginning of the range in text to be matched by a `unordered:` or `not:` directive.
|
// Get the beginning of the range in text to be matched by a `unordered:` or `not:` directive.
|
||||||
// The unordered directive must match after the directives that define the variables used.
|
// The unordered directive must match after the directives that define the variables used.
|
||||||
fn unordered_begin(&self, pat: &Pattern) -> usize {
|
fn unordered_begin(&self, pat: &Pattern) -> usize {
|
||||||
let mut from = self.last_ordered;
|
pat.parts()
|
||||||
for part in pat.parts() {
|
.iter()
|
||||||
if let Some(var) = part.ref_var() {
|
.filter_map(|part| part.ref_var())
|
||||||
from = max(from, self.def_offset(var));
|
.map(|var| self.def_offset(var))
|
||||||
}
|
.fold(self.last_ordered, max)
|
||||||
}
|
|
||||||
from
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the range in text to be matched by a `unordered:` directive.
|
// Get the range in text to be matched by a `unordered:` directive.
|
||||||
|
|||||||
Reference in New Issue
Block a user