File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -32,15 +32,16 @@ impl RegexSet {
3232 & self . items [ ..]
3333 }
3434
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 ( ) ) ;
35+ /// Returns an iterator over regexes in the set which didn't match any
36+ /// strings yet.
37+ pub fn unmatched_items ( & self ) -> impl Iterator < Item = & String > {
38+ self . items . iter ( ) . enumerate ( ) . filter_map ( move | ( i , item ) | {
39+ if self . matched [ i] . get ( ) {
40+ return None ;
4141 }
42- }
43- items
42+
43+ Some ( item)
44+ } )
4445 }
4546
4647 /// Construct a RegexSet from the set of entries we've accumulated.
You can’t perform that action at this time.
0 commit comments