Skip to content

Commit

Permalink
Satisfy Clippy.
Browse files Browse the repository at this point in the history
  • Loading branch information
xStrom committed May 23, 2024
1 parent 5ebb609 commit ee8b035
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
10 changes: 5 additions & 5 deletions fontique/src/backend/fontconfig/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! Extremely naive fontconfig xml parser to extract the data we need.
use roxmltree::Node;
use std::path::Path;
use std::path::{Path, PathBuf};

pub trait ParserSink {
fn include_path(&mut self, path: &Path);
Expand Down Expand Up @@ -175,7 +175,7 @@ fn include_config(path: &Path, sink: &mut impl ParserSink) -> std::io::Result<()
Ok(())
}

fn resolve_dir(node: Node, config_file_path: impl AsRef<Path>) -> Option<std::path::PathBuf> {
fn resolve_dir(node: Node, config_file_path: impl AsRef<Path>) -> Option<PathBuf> {
let dir_path = node.text()?;
let (xdg_env, xdg_fallback) = match node.tag_name().name() {
"include" => ("XDG_CONFIG_HOME", "~/.config"),
Expand All @@ -184,7 +184,7 @@ fn resolve_dir(node: Node, config_file_path: impl AsRef<Path>) -> Option<std::pa
};
let path = match node.attribute("prefix") {
Some("xdg") => {
std::path::PathBuf::from(std::env::var(xdg_env).unwrap_or_else(|_| xdg_fallback.into()))
PathBuf::from(std::env::var(xdg_env).unwrap_or_else(|_| xdg_fallback.into()))
.join(dir_path)
}
_ => {
Expand All @@ -193,14 +193,14 @@ fn resolve_dir(node: Node, config_file_path: impl AsRef<Path>) -> Option<std::pa
} else {
match config_file_path.as_ref().parent() {
Some(parent) => parent.join(dir_path),
None => std::path::Path::new(".").join(dir_path),
None => Path::new(".").join(dir_path),
}
}
}
};
Some(if let Ok(stripped_path) = path.strip_prefix("~") {
let home = config_home().unwrap_or("/".to_string());
std::path::Path::new(&home).join(stripped_path)
Path::new(&home).join(stripped_path)
} else {
path
})
Expand Down
11 changes: 6 additions & 5 deletions fontique/src/backend/fontconfig/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT

use hashbrown::HashMap;
use std::{path::PathBuf, sync::Arc};
use std::path::{Path, PathBuf};
use std::sync::Arc;

use super::{
super::{Stretch, Style, Weight},
Expand Down Expand Up @@ -91,15 +92,15 @@ impl SystemFonts {
config::parse_config("/etc/fonts/fonts.conf".as_ref(), &mut config);
if let Ok(xdg_config_home) = std::env::var("XDG_CONFIG_HOME") {
config::parse_config(
std::path::PathBuf::from(xdg_config_home)
PathBuf::from(xdg_config_home)
.as_path()
.join("fontconfig/fonts.conf")
.as_path(),
&mut config,
);
} else if let Ok(user_home) = std::env::var("HOME") {
config::parse_config(
std::path::PathBuf::from(user_home)
PathBuf::from(user_home)
.as_path()
.join(".config/fontconfig/fonts.conf")
.as_path(),
Expand Down Expand Up @@ -300,9 +301,9 @@ impl config::ParserSink for Config {
}
}

fn include_path(&mut self, _path: &std::path::Path) {}
fn include_path(&mut self, _path: &Path) {}

fn cache_path(&mut self, path: &std::path::Path) {
fn cache_path(&mut self, path: &Path) {
self.cache_dirs.push(path.into());
}

Expand Down

0 comments on commit ee8b035

Please sign in to comment.