We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6bb16ba commit eb85a2bCopy full SHA for eb85a2b
src/regex_set.rs
@@ -32,15 +32,16 @@ impl RegexSet {
32
&self.items[..]
33
}
34
35
- /// Returns regexes in the set which didn't match any strings yet
36
- pub fn unmatched_items(&self) -> Vec<String> {
37
- let mut items = vec![];
38
- for (i, item) in self.items.iter().enumerate() {
39
- if !self.matched[i].get() {
40
- items.push(item.clone());
+ /// Returns an iterator over regexes in the set which didn't match any
+ /// strings yet.
+ pub fn unmatched_items(&self) -> impl Iterator<Item = &String> {
+ self.items.iter().enumerate().filter_map(move |(i, item)| {
+ if self.matched[i].get() {
+ return None;
41
42
- }
43
- items
+
+ Some(item)
44
+ })
45
46
47
/// Construct a RegexSet from the set of entries we've accumulated.
0 commit comments