File tree Expand file tree Collapse file tree 1 file changed +3
-9
lines changed Expand file tree Collapse file tree 1 file changed +3
-9
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ use core::fmt;
4848use core:: hash;
4949#[ cfg( not( no_global_oom_handling) ) ]
5050use core:: iter:: FromIterator ;
51- use core:: iter:: FusedIterator ;
51+ use core:: iter:: { from_fn , FusedIterator } ;
5252#[ cfg( not( no_global_oom_handling) ) ]
5353use core:: ops:: Add ;
5454#[ cfg( not( no_global_oom_handling) ) ]
@@ -1290,15 +1290,9 @@ impl String {
12901290 {
12911291 use core:: str:: pattern:: Searcher ;
12921292
1293- let matches = {
1293+ let matches: Vec < _ > = {
12941294 let mut searcher = pat. into_searcher ( self ) ;
1295- let mut matches = Vec :: new ( ) ;
1296-
1297- while let Some ( m) = searcher. next_match ( ) {
1298- matches. push ( m) ;
1299- }
1300-
1301- matches
1295+ from_fn ( || searcher. next_match ( ) ) . collect ( )
13021296 } ;
13031297
13041298 let len = self . len ( ) ;
You can’t perform that action at this time.
0 commit comments