diff --git a/Cargo.toml b/Cargo.toml index 1cbe970..421f80a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,10 @@ linicon = "2.3.0" gtk4 = "0.4.7" criterion = "0.3.5" +[features] +default = [] +local_tests = [] + [[bench]] name = "simple_lookup" harness = false diff --git a/src/lib.rs b/src/lib.rs index ce05c41..67105cb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -63,7 +63,7 @@ mod theme; /// Return the list of installed themes on the system /// /// ## Example -/// ```rust +/// ```rust,no_run /// # fn main() { /// use freedesktop_icons::list_themes; /// @@ -92,7 +92,7 @@ pub fn list_themes() -> Vec<&'static str> { /// Return the default GTK theme if set. /// /// ## Example -/// ```rust +/// ```rust, no_run /// use freedesktop_icons::default_theme_gtk; /// /// let theme = default_theme_gtk(); @@ -259,11 +259,8 @@ impl<'a> LookupBuilder<'a> { // If the icon was previously search but not found, we return // `None` early, otherwise, attempt to perform a lookup if self.cache { - match self.cache_lookup(self.theme) { - CacheEntry::Found(icon) => { - return Some(icon); - } - _ => {} + if let CacheEntry::Found(icon) = self.cache_lookup(self.theme) { + return Some(icon); }; } @@ -344,6 +341,7 @@ impl<'a> LookupBuilder<'a> { // WARNING: these test are highly dependent on your installed icon-themes. // If you want to run them, make sure you have 'Papirus' and 'Arc' icon-themes installed. #[cfg(test)] +#[cfg(feature = "local_tests")] mod test { use crate::{lookup, CacheEntry, CACHE}; use speculoos::prelude::*; @@ -383,7 +381,7 @@ mod test { .that(&icon) .is_some() .is_equal_to(PathBuf::from( - "/usr/share/icons/Adwaita/scalable/devices/video-single-display-symbolic.svg", + "/usr/share/icons/Adwaita/symbolic/devices/video-single-display-symbolic.svg", )); } diff --git a/src/theme/mod.rs b/src/theme/mod.rs index ee793ba..ac1ef02 100644 --- a/src/theme/mod.rs +++ b/src/theme/mod.rs @@ -14,7 +14,7 @@ mod paths; type Result = std::result::Result; -pub static THEMES: Lazy>> = Lazy::new(|| get_all_themes()); +pub static THEMES: Lazy>> = Lazy::new(get_all_themes); pub struct Theme { pub path: ThemePath, diff --git a/src/theme/paths.rs b/src/theme/paths.rs index 83008ac..93b45d5 100644 --- a/src/theme/paths.rs +++ b/src/theme/paths.rs @@ -55,7 +55,7 @@ mod test { #[test] fn should_get_all_themes() { - let themes = get_all_themes().unwrap(); + let themes = get_all_themes(); assert_that!(themes.get("hicolor")).is_some(); } @@ -67,7 +67,7 @@ mod test { #[test] fn should_read_theme_index() -> Result<()> { - let themes = get_all_themes()?; + let themes = get_all_themes(); let themes: Vec<&Theme> = themes.values().flatten().collect(); assert_that!(themes).is_not_empty(); Ok(())