Skip to content

Commit 8fa7f85

Browse files
authored
chore: change use of map_or to map and unwrap_or in cli helper (#10018)
### Description Refactor to replace `map_or` with `map` and `unwrap_or`. The separation of these two steps makes it clear in the code that the `unwrap_or` case is the default, where it was obscured by the density and argument order of `map_or` before.
1 parent 88f2241 commit 8fa7f85

File tree

1 file changed

+4
-6
lines changed
  • crates/turborepo-lib/src/cli

1 file changed

+4
-6
lines changed

crates/turborepo-lib/src/cli/mod.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -1161,14 +1161,12 @@ enum PrintVersionState {
11611161
}
11621162

11631163
fn get_print_version_state() -> PrintVersionState {
1164-
// map_or is used here because env::var returns Result<String, ...>
1165-
// and we want to compare against str
1166-
env::var("TURBO_PRINT_VERSION_DISABLED").map_or(PrintVersionState::Enabled, |var| {
1167-
match var.as_str() {
1164+
env::var("TURBO_PRINT_VERSION_DISABLED")
1165+
.map(|var| match var.as_str() {
11681166
"1" | "true" => PrintVersionState::Disabled,
11691167
_ => PrintVersionState::Enabled,
1170-
}
1171-
})
1168+
})
1169+
.unwrap_or(PrintVersionState::Enabled)
11721170
}
11731171

11741172
#[derive(PartialEq)]

0 commit comments

Comments
 (0)