File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -963,10 +963,11 @@ pub fn run_cargo(
963963 . collect :: < Vec < _ > > ( ) ;
964964 for ( prefix, extension, expected_len) in toplevel {
965965 let candidates = contents. iter ( ) . filter ( |& & ( _, ref filename, ref meta) | {
966- filename. starts_with ( & prefix[ ..] )
967- && filename[ prefix. len ( ) ..] . starts_with ( '-' )
968- && filename. ends_with ( & extension[ ..] )
969- && meta. len ( ) == expected_len
966+ meta. len ( ) == expected_len
967+ && filename
968+ . strip_prefix ( & prefix[ ..] )
969+ . map ( |s| s. starts_with ( '-' ) && s. ends_with ( & extension[ ..] ) )
970+ . unwrap_or ( false )
970971 } ) ;
971972 let max = candidates
972973 . max_by_key ( |& & ( _, _, ref metadata) | FileTime :: from_last_modification_time ( metadata) ) ;
Original file line number Diff line number Diff line change @@ -436,10 +436,9 @@ impl Build {
436436 output ( Command :: new ( & build. initial_rustc ) . arg ( "--version" ) . arg ( "--verbose" ) ) ;
437437 let local_release = local_version_verbose
438438 . lines ( )
439- . filter ( |x| x. starts_with ( "release:" ) )
439+ . filter_map ( |x| x. strip_prefix ( "release:" ) )
440440 . next ( )
441441 . unwrap ( )
442- . trim_start_matches ( "release:" )
443442 . trim ( ) ;
444443 let my_version = channel:: CFG_RELEASE_NUM ;
445444 if local_release. split ( '.' ) . take ( 2 ) . eq ( my_version. split ( '.' ) . take ( 2 ) ) {
@@ -1089,10 +1088,10 @@ impl Build {
10891088 let toml_file_name = self . src . join ( & format ! ( "src/tools/{}/Cargo.toml" , package) ) ;
10901089 let toml = t ! ( fs:: read_to_string( & toml_file_name) ) ;
10911090 for line in toml. lines ( ) {
1092- let prefix = "version = \" " ;
1093- let suffix = " \" ";
1094- if line . starts_with ( prefix ) && line . ends_with ( suffix ) {
1095- return line [ prefix . len ( ) ..line . len ( ) - suffix . len ( ) ] . to_string ( ) ;
1091+ if let Some ( stripped ) =
1092+ line . strip_prefix ( "version = \" " ) . and_then ( |s| s . strip_suffix ( " \" ") )
1093+ {
1094+ return stripped . to_owned ( ) ;
10961095 }
10971096 }
10981097
You can’t perform that action at this time.
0 commit comments