Skip to content

Unexpected SetMatches::len() behavior #625

Closed
@EFanZh

Description

@EFanZh

The document explains SetMatches::len() as “the total number of regexes in the set that created these matches”.

At first sight, I thought SetMatches as a collection of matched regular expression indices, so naturally, I expect the following function to always return true:

fn f(s: &SetMatches) -> bool {
    s.len() == s.iter().count()
}

But it seems that this method always returns the number of all regular expressions in the corresponding RegexSet object, not the number of matched regular expressions.

I think the name of len() strongly suggests that it is consistent with the behavior of iter(), maybe it’s better to rename this method or add a better explanation to reduce confusion.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions