Rename cx.global_default_mut
to cx.global_default
This commit is contained in:
parent
4ca7ddfc42
commit
d6bd000aa8
14 changed files with 52 additions and 50 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue