mirror of
https://github.com/danbulant/icon
synced 2026-06-17 05:11:20 +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
|
|
@ -259,9 +259,17 @@ impl IconLocations {
|
|||
|
||||
pub fn icons(self) -> Icons {
|
||||
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 {
|
||||
standalone_icons: self.standalone_icons,
|
||||
standalone_icons,
|
||||
themes,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use std::sync::Arc;
|
|||
/// Icons::new().find_icon("firefox", 32, 1, "hicolor");
|
||||
/// ```
|
||||
pub struct Icons {
|
||||
pub standalone_icons: Vec<IconFile>,
|
||||
pub standalone_icons: HashMap<String, IconFile>,
|
||||
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.
|
||||
pub fn find_standalone_icon(&self, icon_name: &str) -> Option<IconFile> {
|
||||
self.standalone_icons
|
||||
.iter()
|
||||
.find(|ico| ico.path.file_stem() == Some(icon_name.as_ref()))
|
||||
self.standalone_icons.get(icon_name)
|
||||
.cloned()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue