summaryrefslogtreecommitdiff
path: root/cli/version.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-03-15 17:46:36 -0400
committerGitHub <noreply@github.com>2023-03-15 17:46:36 -0400
commitfb021d7ceff3f8b1d7cdb0c2bdd75ea07c0428d2 (patch)
tree09cb2bf87bba760b1abf706e0b8faedc9c368bbc /cli/version.rs
parentca51f4f6c058d16ac438ad75ac92e8954895f5aa (diff)
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<T>` and that clippy should suggest rewriting to `map(...).unwrap_or(...)`/`map(...).unwrap_or_else(|| ...)` https://github.com/rust-lang/rfcs/issues/1025
Diffstat (limited to 'cli/version.rs')
-rw-r--r--cli/version.rs8
1 files changed, 4 insertions, 4 deletions
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 {