chore(icon_theme): store default theme as Cow<str>

This commit is contained in:
Michael Aaron Murphy 2023-09-01 07:26:00 +02:00 committed by Michael Murphy
parent 2ab760e66d
commit 5904d2c0f0

View file

@ -3,20 +3,21 @@
//! Select the preferred icon theme.
use std::borrow::Cow;
use std::cell::RefCell;
thread_local! {
/// The fallback icon theme to search if no icon theme was specified.
pub(crate) static DEFAULT: RefCell<String> = RefCell::new(String::from("Cosmic"));
pub(crate) static DEFAULT: RefCell<Cow<'static, str>> = RefCell::new("Cosmic".into());
}
/// The fallback icon theme to search if no icon theme was specified.
#[must_use]
pub fn default() -> String {
DEFAULT.with(|f| f.borrow().clone())
DEFAULT.with(|theme| theme.borrow().to_string())
}
/// Set the fallback icon theme to search when loading system icons.
pub fn set_default(name: impl Into<String>) {
DEFAULT.with(|f| *f.borrow_mut() = name.into());
pub fn set_default(name: impl Into<Cow<'static, str>>) {
DEFAULT.with(|theme| *theme.borrow_mut() = name.into());
}