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:
parent
e0da57df3f
commit
c8a787475c
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user