Skip to content

RegexSet matched_any() yields true, but iter() returns no indexes #187

@dprien

Description

@dprien

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].

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions