Skip to content

Commit 61be2c8

Browse files
committed
fix: clippy issues
1 parent fa2e15d commit 61be2c8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/config.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyhow::{Context, Result};
22
use serde::Deserialize;
3-
use std::{env, fs, path::PathBuf};
3+
use std::{env, fs, path::{Path, PathBuf}};
44

55
/// Represents global application settings loaded from cmdy.toml.
66
#[derive(Debug, Deserialize)]
@@ -22,15 +22,15 @@ impl Default for AppConfig {
2222
}
2323
}
2424

25-
fn expand_tilde(path: &PathBuf) -> PathBuf {
25+
fn expand_tilde(path: &Path) -> PathBuf {
2626
if let Some(path_str) = path.to_str() {
27-
if path_str.starts_with("~/") {
27+
if let Some(stripped) = path_str.strip_prefix("~/") {
2828
if let Ok(home) = env::var("HOME") {
29-
return PathBuf::from(home).join(&path_str[2..]);
29+
return PathBuf::from(home).join(stripped);
3030
}
3131
}
3232
}
33-
path.clone()
33+
path.to_path_buf()
3434
}
3535

3636
/// Loads the application configuration from a TOML file.
@@ -54,7 +54,7 @@ pub fn load_app_config() -> Result<AppConfig> {
5454
.with_context(|| format!("Failed to read config file: {}", config_path.display()))?;
5555
match toml::from_str::<AppConfig>(&content) {
5656
Ok(mut cfg) => {
57-
cfg.directories = cfg.directories.iter().map(expand_tilde).collect();
57+
cfg.directories = cfg.directories.iter().map(|p| expand_tilde(p)).collect();
5858
return Ok(cfg);
5959
}
6060
Err(e) => eprintln!(

0 commit comments

Comments
 (0)