aboutsummaryrefslogtreecommitdiffstats
path: root/src/dirs.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2023-02-18 15:38:43 -0500
committerJesse Luehrs <doy@tozt.net>2023-02-18 15:49:17 -0500
commit1d68b717e8ae12dfdf8af9c451dbf0d6a8cc6d71 (patch)
tree9416fd8d1bc125aa6f217d6cbc6340e27655bb99 /src/dirs.rs
parentc6a948a5cfa2783907c084cc8d1034c33db319e6 (diff)
downloadrbw-1d68b717e8ae12dfdf8af9c451dbf0d6a8cc6d71.tar.gz
rbw-1d68b717e8ae12dfdf8af9c451dbf0d6a8cc6d71.zip
clippy
Diffstat (limited to 'src/dirs.rs')
-rw-r--r--src/dirs.rs26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/dirs.rs b/src/dirs.rs
index 429f8bd..e838e12 100644
--- a/src/dirs.rs
+++ b/src/dirs.rs
@@ -49,7 +49,7 @@ pub fn db_file(server: &str, email: &str) -> std::path::PathBuf {
let server =
percent_encoding::percent_encode(server.as_bytes(), INVALID_PATH)
.to_string();
- cache_dir().join(format!("{}:{}.json", server, email))
+ cache_dir().join(format!("{server}:{email}.json"))
}
#[must_use]
@@ -102,22 +102,24 @@ fn data_dir() -> std::path::PathBuf {
fn runtime_dir() -> std::path::PathBuf {
let project_dirs =
directories::ProjectDirs::from("", "", &profile()).unwrap();
- match project_dirs.runtime_dir() {
- Some(dir) => dir.to_path_buf(),
- None => format!(
- "{}/{}-{}",
- std::env::temp_dir().to_string_lossy(),
- &profile(),
- nix::unistd::getuid().as_raw()
- )
- .into(),
- }
+ project_dirs.runtime_dir().map_or_else(
+ || {
+ format!(
+ "{}/{}-{}",
+ std::env::temp_dir().to_string_lossy(),
+ &profile(),
+ nix::unistd::getuid().as_raw()
+ )
+ .into()
+ },
+ std::path::Path::to_path_buf,
+ )
}
#[must_use]
pub fn profile() -> String {
match std::env::var("RBW_PROFILE") {
- Ok(profile) if !profile.is_empty() => format!("rbw-{}", profile),
+ Ok(profile) if !profile.is_empty() => format!("rbw-{profile}"),
_ => "rbw".to_string(),
}
}