refactor: use `unwrap_or_default` (#2516)
This commit is contained in:
parent
e0da57df3f
commit
c8a787475c
|
@ -140,11 +140,11 @@ fn get_editor() -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_editor_internal(visual: Option<String>, editor: Option<String>) -> 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() {
|
if !editor_name.is_empty() {
|
||||||
return editor_name;
|
return editor_name;
|
||||||
}
|
}
|
||||||
let editor_name = editor.unwrap_or_else(|| "".into());
|
let editor_name = editor.unwrap_or_default();
|
||||||
if !editor_name.is_empty() {
|
if !editor_name.is_empty() {
|
||||||
return editor_name;
|
return editor_name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,7 @@ use crate::formatter::StringFormatter;
|
||||||
/// Will display the Conda environment iff `$CONDA_DEFAULT_ENV` is set.
|
/// Will display the Conda environment iff `$CONDA_DEFAULT_ENV` is set.
|
||||||
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
||||||
// Reference implementation: https://github.com/denysdovhan/spaceship-prompt/blob/master/sections/conda.zsh
|
// Reference implementation: https://github.com/denysdovhan/spaceship-prompt/blob/master/sections/conda.zsh
|
||||||
let conda_env = context
|
let conda_env = context.get_env("CONDA_DEFAULT_ENV").unwrap_or_default();
|
||||||
.get_env("CONDA_DEFAULT_ENV")
|
|
||||||
.unwrap_or_else(|| "".into());
|
|
||||||
if conda_env.trim().is_empty() {
|
if conda_env.trim().is_empty() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue