-
Notifications
You must be signed in to change notification settings - Fork 481
Closed
Labels
Description
Unfortunately, it looks like 3fb34e2 (the fix for #186) introduced a bug in RegexSet:
extern crate regex;
fn main() {
let set = regex::RegexSet::new(&[r"^\s+", r"^[a-z]+"]).unwrap();
let r1 = set.matches("lorem ipsum dolor");
assert!(r1.matched_any());
println!("{:?}, {:?}", r1, r1.iter().collect::<Vec<_>>());
let r2 = set.matches("ipsum dolor");
assert!(r2.matched_any());
println!("{:?}, {:?}", r2, r2.iter().collect::<Vec<_>>());
}
Output:
SetMatches { matched_any: true, matches: [false, true] }, [1]
SetMatches { matched_any: true, matches: [false, false] }, []
That is, the second call to matches
claims a match has been found, but iter()
does not return any indexes.
Curiously, if you omit the first matches
call, the second call works as expected, yielding SetMatches { matched_any: true, matches: [false, true] }, [1]
.