mirror of
https://github.com/danbulant/icon
synced 2026-07-03 10:00:37 +00:00
Convert standalone_icons to a map
This commit is contained in:
parent
79dbfa3c09
commit
15e73777a1
2 changed files with 11 additions and 5 deletions
|
|
@ -260,8 +260,16 @@ impl IconLocations {
|
||||||
pub fn icons(self) -> Icons {
|
pub fn icons(self) -> Icons {
|
||||||
let themes = self.resolve();
|
let themes = self.resolve();
|
||||||
|
|
||||||
|
let standalone_icons = self.standalone_icons
|
||||||
|
.into_iter()
|
||||||
|
.map(|file| {
|
||||||
|
let key = file.path.file_stem().map(|s| s.to_string_lossy().to_string()).unwrap_or(String::new());
|
||||||
|
(key, file)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
Icons {
|
Icons {
|
||||||
standalone_icons: self.standalone_icons,
|
standalone_icons,
|
||||||
themes,
|
themes,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ use std::sync::Arc;
|
||||||
/// Icons::new().find_icon("firefox", 32, 1, "hicolor");
|
/// Icons::new().find_icon("firefox", 32, 1, "hicolor");
|
||||||
/// ```
|
/// ```
|
||||||
pub struct Icons {
|
pub struct Icons {
|
||||||
pub standalone_icons: Vec<IconFile>,
|
pub standalone_icons: HashMap<String, IconFile>,
|
||||||
pub themes: HashMap<OsString, Arc<Theme>>,
|
pub themes: HashMap<OsString, Arc<Theme>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,9 +82,7 @@ impl Icons {
|
||||||
///
|
///
|
||||||
/// These icons do not have any size or scalability information attached to them.
|
/// These icons do not have any size or scalability information attached to them.
|
||||||
pub fn find_standalone_icon(&self, icon_name: &str) -> Option<IconFile> {
|
pub fn find_standalone_icon(&self, icon_name: &str) -> Option<IconFile> {
|
||||||
self.standalone_icons
|
self.standalone_icons.get(icon_name)
|
||||||
.iter()
|
|
||||||
.find(|ico| ico.path.file_stem() == Some(icon_name.as_ref()))
|
|
||||||
.cloned()
|
.cloned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue