Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit da6b1e5

Browse files
committedApr 17, 2023
doc: clarify meaning of SetMatches::len
It is really unfortunate, but SetMatches::len and SetMatcher::iter().count() do not correspond go the same thing. It's not clear why I even added the SetMatches::len method in the first place, but it always returns the number of regexes in the set, and not the number of regexes that matched. We can't change the name (or remove the method) obviously, but we do add a warning to the docs. Fixes #625
1 parent e3e8995 commit da6b1e5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed
 

‎src/re_set.rs

+5
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,11 @@ impl SetMatches {
321321
}
322322

323323
/// The total number of regexes in the set that created these matches.
324+
///
325+
/// **WARNING:** This always returns the same value as [`RegexSet::len`].
326+
/// In particular, it does *not* return the number of elements yielded by
327+
/// [`SetMatches::iter`]. The only way to determine the total number of
328+
/// matched regexes is to iterate over them.
324329
pub fn len(&self) -> usize {
325330
self.matches.len()
326331
}

0 commit comments

Comments
 (0)
Please sign in to comment.