@@ -19,15 +19,14 @@ const PYTHON2: &str = "python2";
1919const PYTHON3 : & str = "python3" ;
2020
2121fn python ( ) -> & ' static str {
22- let val = match env:: var_os ( "PATH" ) {
23- Some ( val) => val,
24- None => return PYTHON ,
22+ let Some ( path) = env:: var_os ( "PATH" ) else {
23+ return PYTHON ;
2524 } ;
2625
2726 let mut python2 = false ;
2827 let mut python3 = false ;
2928
30- for dir in env:: split_paths ( & val ) {
29+ for dir in env:: split_paths ( & path ) {
3130 // `python` should always take precedence over python2 / python3 if it exists
3231 if dir. join ( PYTHON ) . with_extension ( EXE_EXTENSION ) . exists ( ) {
3332 return PYTHON ;
@@ -89,7 +88,7 @@ fn exec_or_status(command: &mut Command) -> io::Result<ExitStatus> {
8988fn handle_result ( result : io:: Result < ExitStatus > , cmd : Command ) {
9089 match result {
9190 Err ( error) => {
92- eprintln ! ( "Failed to invoke `{:?}`: {}" , cmd , error ) ;
91+ eprintln ! ( "Failed to invoke `{cmd :?}`: {error}" ) ;
9392 }
9493 Ok ( status) => {
9594 process:: exit ( status. code ( ) . unwrap_or ( 1 ) ) ;
@@ -98,22 +97,19 @@ fn handle_result(result: io::Result<ExitStatus>, cmd: Command) {
9897}
9998
10099fn main ( ) {
101- match env:: args ( ) . skip ( 1 ) . next ( ) . as_deref ( ) {
102- Some ( "--wrapper-version" ) => {
103- let version = env ! ( "CARGO_PKG_VERSION" ) ;
104- println ! ( "{}" , version) ;
105- return ;
106- }
107- _ => { }
100+ if env:: args ( ) . nth ( 1 ) . is_some_and ( |s| s == "--wrapper-version" ) {
101+ let version = env ! ( "CARGO_PKG_VERSION" ) ;
102+ println ! ( "{version}" ) ;
103+ return ;
108104 }
105+
109106 let current = match env:: current_dir ( ) {
110107 Ok ( dir) => dir,
111108 Err ( err) => {
112109 eprintln ! ( "Failed to get current directory: {err}" ) ;
113110 process:: exit ( 1 ) ;
114111 }
115112 } ;
116-
117113 for dir in current. ancestors ( ) {
118114 let candidate = dir. join ( "x.py" ) ;
119115 if candidate. exists ( ) {
0 commit comments