1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-11-05 04:47:58 +00:00

refactor: use unwrap_or_default (#2516)

This commit is contained in:
Dario Vladović 2021-03-26 21:01:20 +01:00 committed by GitHub
parent e0da57df3f
commit c8a787475c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View File

@ -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;
}

View File

@ -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;
}