Rename cx.global_default_mut to cx.global_default

This commit is contained in:
Marshall Bowers 2023-10-24 17:58:14 +02:00
parent 4ca7ddfc42
commit d6bd000aa8
14 changed files with 52 additions and 50 deletions

View file

@ -8,16 +8,6 @@ pub struct ThemeRegistry {
}
impl ThemeRegistry {
pub fn new() -> Self {
let mut this = Self {
themes: HashMap::default(),
};
this.insert_themes([one_dark()]);
this
}
fn insert_themes(&mut self, themes: impl IntoIterator<Item = Theme>) {
for theme in themes.into_iter() {
self.themes
@ -33,11 +23,22 @@ impl ThemeRegistry {
self.themes.values().map(|theme| theme.metadata.clone())
}
pub fn get(&self, name: impl Into<SharedString>) -> Result<Arc<Theme>> {
let name = name.into();
pub fn get(&self, name: &str) -> Result<Arc<Theme>> {
self.themes
.get(&name)
.get(name)
.ok_or_else(|| anyhow!("theme not found: {}", name))
.cloned()
}
}
impl Default for ThemeRegistry {
fn default() -> Self {
let mut this = Self {
themes: HashMap::default(),
};
this.insert_themes([one_dark()]);
this
}
}