From c8a787475ca81e4df738cc6180e2b15600bc7f42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dario=20Vladovi=C4=87?= Date: Fri, 26 Mar 2021 21:01:20 +0100 Subject: [PATCH] refactor: use `unwrap_or_default` (#2516) --- src/configure.rs | 4 ++-- src/modules/conda.rs | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/configure.rs b/src/configure.rs index 48f765aa..415a1e0b 100644 --- a/src/configure.rs +++ b/src/configure.rs @@ -140,11 +140,11 @@ fn get_editor() -> String { } fn get_editor_internal(visual: Option, editor: Option) -> 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 70878b73..025a99ca 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> { // 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; }