From 2aba8210678c963dbf43970090db656e7b50f5a0 Mon Sep 17 00:00:00 2001 From: Eduardo Flores Date: Wed, 9 Aug 2023 21:23:45 -0700 Subject: [PATCH] Manual implementation - Added manual implementation to allow the property to be set to None. --- src/app/settings.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/app/settings.rs b/src/app/settings.rs index 93cda035..fd71e6df 100644 --- a/src/app/settings.rs +++ b/src/app/settings.rs @@ -26,7 +26,7 @@ pub struct Settings { pub(crate) default_font: Font, /// Name of the icon theme to search by default. - #[setters(into, strip_option)] + #[setters(skip)] pub(crate) default_icon_theme: Option, /// Default size of fonts. @@ -53,6 +53,19 @@ pub struct Settings { pub(crate) transparent: bool, } +impl Settings { + /// Sets the default icon theme, passing an empty string will unset the theme. + pub fn default_icon_theme(mut self, value: impl Into) -> Self { + let value: String = value.into(); + self.default_icon_theme = if value.is_empty() { + None + } else { + Some(value.to_string()) + }; + self + } +} + impl Default for Settings { fn default() -> Self { Self {