diff --git a/src/search.rs b/src/search.rs index e50dacd..38dd19f 100644 --- a/src/search.rs +++ b/src/search.rs @@ -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, } } diff --git a/src/theme.rs b/src/theme.rs index a0ec2ec..9451f24 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -20,7 +20,7 @@ use std::sync::Arc; /// Icons::new().find_icon("firefox", 32, 1, "hicolor"); /// ``` pub struct Icons { - pub standalone_icons: Vec, + pub standalone_icons: HashMap, pub themes: HashMap>, } @@ -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 { - self.standalone_icons - .iter() - .find(|ico| ico.path.file_stem() == Some(icon_name.as_ref())) + self.standalone_icons.get(icon_name) .cloned() } }