Commit 481988b 1 parent e59b08e commit 481988b Copy full SHA for 481988b
File tree 2 files changed +10
-10
lines changed
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(
963
963
. collect :: < Vec < _ > > ( ) ;
964
964
for ( prefix, extension, expected_len) in toplevel {
965
965
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 )
970
971
} ) ;
971
972
let max = candidates
972
973
. 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 {
436
436
output ( Command :: new ( & build. initial_rustc ) . arg ( "--version" ) . arg ( "--verbose" ) ) ;
437
437
let local_release = local_version_verbose
438
438
. lines ( )
439
- . filter ( |x| x. starts_with ( "release:" ) )
439
+ . filter_map ( |x| x. strip_prefix ( "release:" ) )
440
440
. next ( )
441
441
. unwrap ( )
442
- . trim_start_matches ( "release:" )
443
442
. trim ( ) ;
444
443
let my_version = channel:: CFG_RELEASE_NUM ;
445
444
if local_release. split ( '.' ) . take ( 2 ) . eq ( my_version. split ( '.' ) . take ( 2 ) ) {
@@ -1089,10 +1088,10 @@ impl Build {
1089
1088
let toml_file_name = self . src . join ( & format ! ( "src/tools/{}/Cargo.toml" , package) ) ;
1090
1089
let toml = t ! ( fs:: read_to_string( & toml_file_name) ) ;
1091
1090
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 ( ) ;
1096
1095
}
1097
1096
}
1098
1097
You can’t perform that action at this time.
0 commit comments