From fb021d7ceff3f8b1d7cdb0c2bdd75ea07c0428d2 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 15 Mar 2023 17:46:36 -0400 Subject: refactor: remove usages of `map_or` / `map_or_else` (#18212) These methods are confusing because the arguments are backwards. I feel like they should have never been added to `Option` and that clippy should suggest rewriting to `map(...).unwrap_or(...)`/`map(...).unwrap_or_else(|| ...)` https://github.com/rust-lang/rfcs/issues/1025 --- cli/version.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'cli/version.rs') diff --git a/cli/version.rs b/cli/version.rs index c4696620e..88dc9ffc7 100644 --- a/cli/version.rs +++ b/cli/version.rs @@ -4,10 +4,10 @@ pub const GIT_COMMIT_HASH: &str = env!("GIT_COMMIT_HASH"); pub const TYPESCRIPT: &str = env!("TS_VERSION"); pub fn deno() -> String { - let semver = env!("CARGO_PKG_VERSION"); - option_env!("DENO_CANARY").map_or(semver.to_string(), |_| { - format!("{}+{}", semver, &GIT_COMMIT_HASH[..7]) - }) + let version = env!("CARGO_PKG_VERSION"); + option_env!("DENO_CANARY") + .map(|_| format!("{}+{}", version, &GIT_COMMIT_HASH[..7])) + .unwrap_or_else(|| version.to_string()) } pub fn is_canary() -> bool { -- cgit v1.2.3