Skip to content

Commit dcf965d

Browse files
committed
x: use let-else
1 parent b87a1b1 commit dcf965d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/tools/x/src/main.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@ const PYTHON2: &str = "python2";
1919
const PYTHON3: &str = "python3";
2020

2121
fn 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;
@@ -103,14 +102,14 @@ fn main() {
103102
println!("{version}");
104103
return;
105104
}
105+
106106
let current = match env::current_dir() {
107107
Ok(dir) => dir,
108108
Err(err) => {
109109
eprintln!("Failed to get current directory: {err}");
110110
process::exit(1);
111111
}
112112
};
113-
114113
for dir in current.ancestors() {
115114
let candidate = dir.join("x.py");
116115
if candidate.exists() {

0 commit comments

Comments
 (0)