chore: migrate to Rust 2024 and update dependencies
This commit is contained in:
parent
32975f8f05
commit
689c60d428
6 changed files with 33 additions and 46 deletions
|
|
@ -130,32 +130,20 @@ fn try_build_svg<P: AsRef<Path>>(name: &str, path: P) -> Option<PathBuf> {
|
|||
let path = path.as_ref();
|
||||
let svg = path.join(format!("{name}.svg"));
|
||||
|
||||
if svg.exists() {
|
||||
Some(svg)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if svg.exists() { Some(svg) } else { None }
|
||||
}
|
||||
|
||||
fn try_build_png<P: AsRef<Path>>(name: &str, path: P) -> Option<PathBuf> {
|
||||
let path = path.as_ref();
|
||||
let png = path.join(format!("{name}.png"));
|
||||
|
||||
if png.exists() {
|
||||
Some(png)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if png.exists() { Some(png) } else { None }
|
||||
}
|
||||
|
||||
fn try_build_xmp<P: AsRef<Path>>(name: &str, path: P) -> Option<PathBuf> {
|
||||
let path = path.as_ref();
|
||||
let xmp = path.join(format!("{name}.xmp"));
|
||||
if xmp.exists() {
|
||||
Some(xmp)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if xmp.exists() { Some(xmp) } else { None }
|
||||
}
|
||||
|
||||
// Iter through the base paths and get all theme directories
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::theme::directories::{Directory, DirectoryType};
|
||||
use crate::theme::Theme;
|
||||
use crate::theme::directories::{Directory, DirectoryType};
|
||||
|
||||
fn icon_theme_section(file: &str) -> impl Iterator<Item = (&str, &str)> + '_ {
|
||||
ini_core::Parser::new(file)
|
||||
|
|
@ -24,7 +24,7 @@ enum DirectorySection<'a> {
|
|||
Section(&'a str),
|
||||
}
|
||||
|
||||
fn sections(file: &str) -> impl Iterator<Item = DirectorySection> {
|
||||
fn sections(file: &str) -> impl Iterator<Item = DirectorySection<'_>> {
|
||||
ini_core::Parser::new(file).filter_map(move |item| match item {
|
||||
ini_core::Item::Property(key, Some(value)) => Some(DirectorySection::Property(key, value)),
|
||||
ini_core::Item::Section(section) => Some(DirectorySection::Section(section)),
|
||||
|
|
|
|||
|
|
@ -11,19 +11,18 @@ pub(crate) static BASE_PATHS: LazyLock<Vec<PathBuf>> = LazyLock::new(icon_theme_
|
|||
/// Look in $HOME/.icons (for backwards compatibility), in $XDG_DATA_DIRS/icons, in $XDG_DATA_DIRS/pixmaps and in /usr/share/pixmaps (in that order).
|
||||
/// Paths that are not found are filtered out.
|
||||
fn icon_theme_base_paths() -> Vec<PathBuf> {
|
||||
let mut data_dirs: Vec<_> = BaseDirectories::new()
|
||||
.map(|bd| {
|
||||
let mut data_dirs: Vec<_> = bd
|
||||
.get_data_dirs()
|
||||
.into_iter()
|
||||
.flat_map(|p| [p.join("icons"), p.join("pixmaps")])
|
||||
.collect();
|
||||
let data_home = bd.get_data_home();
|
||||
data_dirs.push(data_home.join("icons"));
|
||||
data_dirs.push(data_home.join("pixmaps"));
|
||||
data_dirs
|
||||
})
|
||||
.unwrap_or_default();
|
||||
let base_dirs = BaseDirectories::new();
|
||||
let mut data_dirs: Vec<_> = base_dirs
|
||||
.get_data_dirs()
|
||||
.into_iter()
|
||||
.flat_map(|p| [p.join("icons"), p.join("pixmaps")])
|
||||
.collect();
|
||||
|
||||
if let Some(data_home) = base_dirs.get_data_home() {
|
||||
data_dirs.push(data_home.join("icons"));
|
||||
data_dirs.push(data_home.join("pixmaps"));
|
||||
}
|
||||
|
||||
match home_dir().map(|home| home.join(".icons")) {
|
||||
Some(home_icon_dir) => data_dirs.push(home_icon_dir),
|
||||
None => tracing::warn!("No $HOME directory found"),
|
||||
|
|
@ -49,7 +48,7 @@ impl ThemePath {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::theme::paths::icon_theme_base_paths;
|
||||
use crate::theme::{get_all_themes, Theme};
|
||||
use crate::theme::{Theme, get_all_themes};
|
||||
use speculoos::prelude::*;
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue