refactor: fix clippy lints
This commit is contained in:
parent
b7c9865412
commit
8f852b4d8f
2 changed files with 16 additions and 8 deletions
18
src/cache.rs
18
src/cache.rs
|
|
@ -1,24 +1,32 @@
|
|||
use once_cell::sync::Lazy;
|
||||
use std::collections::BTreeMap;
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Mutex;
|
||||
|
||||
pub(crate) static CACHE: Lazy<Cache> = Lazy::new(Cache::default);
|
||||
type IconMap = BTreeMap<(String, u16, u16), PathBuf>;
|
||||
type ThemeMap = BTreeMap<String, IconMap>;
|
||||
|
||||
#[derive(Default)]
|
||||
pub(crate) struct Cache(Mutex<BTreeMap<String, BTreeMap<(String, u16, u16), PathBuf>>>);
|
||||
pub(crate) struct Cache(Mutex<ThemeMap>);
|
||||
|
||||
impl Cache {
|
||||
pub fn insert(&self, theme: &str, size: u16, scale: u16, icon_name: &str, icon_path: &PathBuf) {
|
||||
pub fn insert(&self, theme: &str, size: u16, scale: u16, icon_name: &str, icon_path: &Path) {
|
||||
let mut theme_map = self.0.lock().unwrap();
|
||||
|
||||
match theme_map.get_mut(theme) {
|
||||
Some(icon_map) => {
|
||||
icon_map.insert((icon_name.to_string(), size, scale), icon_path.clone());
|
||||
icon_map.insert(
|
||||
(icon_name.to_string(), size, scale),
|
||||
icon_path.to_path_buf(),
|
||||
);
|
||||
}
|
||||
None => {
|
||||
let mut icon_map = BTreeMap::new();
|
||||
icon_map.insert((icon_name.to_string(), size, scale), icon_path.clone());
|
||||
icon_map.insert(
|
||||
(icon_name.to_string(), size, scale),
|
||||
icon_path.to_path_buf(),
|
||||
);
|
||||
theme_map.insert(theme.to_string(), icon_map);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ impl Theme {
|
|||
self.get_icon_theme_section()
|
||||
.and_then(|props| props.get("ScaledDirectories"))
|
||||
.map(|dirs| dirs.split(',').collect())
|
||||
.unwrap_or(vec![])
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn get_icon_theme_section(&self) -> Option<&Properties> {
|
||||
|
|
@ -30,7 +30,7 @@ impl Theme {
|
|||
self.get_icon_theme_section()
|
||||
.and_then(|props| props.get("Inherits"))
|
||||
.map(|parents| parents.split(',').collect())
|
||||
.unwrap_or(vec![])
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn directories(&self) -> Vec<&str> {
|
||||
|
|
@ -38,7 +38,7 @@ impl Theme {
|
|||
.section(Some("Icon Theme"))
|
||||
.and_then(|props| props.get("Directories"))
|
||||
.map(|dirs| dirs.split(',').collect())
|
||||
.unwrap_or(vec![])
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn get_directory<'a>(&'a self, name: &'a str) -> Option<Directory> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue