diff options
author | Dario Vladović <d.vladimyr@gmail.com> | 2021-03-26 21:01:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-26 21:01:20 +0100 |
commit | c8a787475ca81e4df738cc6180e2b15600bc7f42 (patch) | |
tree | 981fb261f1a04073e83ae6a96262afb1afb68a72 /src | |
parent | e0da57df3febe194aa2541e09167869c330cb77f (diff) |
refactor: use `unwrap_or_default` (#2516)
Diffstat (limited to 'src')
-rw-r--r-- | src/configure.rs | 4 | ||||
-rw-r--r-- | src/modules/conda.rs | 4 |
2 files changed, 3 insertions, 5 deletions
diff --git a/src/configure.rs b/src/configure.rs index 48f765aa9..415a1e0bc 100644 --- a/src/configure.rs +++ b/src/configure.rs @@ -140,11 +140,11 @@ fn get_editor() -> String { } fn get_editor_internal(visual: Option<String>, editor: Option<String>) -> String { - let editor_name = visual.unwrap_or_else(|| "".into()); + let editor_name = visual.unwrap_or_default(); if !editor_name.is_empty() { return editor_name; } - let editor_name = editor.unwrap_or_else(|| "".into()); + let editor_name = editor.unwrap_or_default(); if !editor_name.is_empty() { return editor_name; } diff --git a/src/modules/conda.rs b/src/modules/conda.rs index 70878b73d..025a99cad 100644 --- a/src/modules/conda.rs +++ b/src/modules/conda.rs @@ -9,9 +9,7 @@ use crate::formatter::StringFormatter; /// Will display the Conda environment iff `$CONDA_DEFAULT_ENV` is set. pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { // Reference implementation: https://github.com/denysdovhan/spaceship-prompt/blob/master/sections/conda.zsh - let conda_env = context - .get_env("CONDA_DEFAULT_ENV") - .unwrap_or_else(|| "".into()); + let conda_env = context.get_env("CONDA_DEFAULT_ENV").unwrap_or_default(); if conda_env.trim().is_empty() { return None; } |