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;
48
48
use core:: hash;
49
49
#[ cfg( not( no_global_oom_handling) ) ]
50
50
use core:: iter:: FromIterator ;
51
- use core:: iter:: FusedIterator ;
51
+ use core:: iter:: { from_fn , FusedIterator } ;
52
52
#[ cfg( not( no_global_oom_handling) ) ]
53
53
use core:: ops:: Add ;
54
54
#[ cfg( not( no_global_oom_handling) ) ]
@@ -1290,15 +1290,9 @@ impl String {
1290
1290
{
1291
1291
use core:: str:: pattern:: Searcher ;
1292
1292
1293
- let matches = {
1293
+ let matches: Vec < _ > = {
1294
1294
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 ( )
1302
1296
} ;
1303
1297
1304
1298
let len = self . len ( ) ;
You can’t perform that action at this time.
0 commit comments