summaryrefslogtreecommitdiff
path: root/crates/vcs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2025-09-26 11:18:08 +0800
committer魏曹先生 <1992414357@qq.com>2025-09-26 11:18:08 +0800
commit9c44621f13f27e7f2a82fa5ab2fc8e27381f3e39 (patch)
treed71490fc662508674a2927e9558bc89e91e070b6 /crates/vcs
parentdfaff711cd1cc5d500599a3146891f72f6903c45 (diff)
Fixed by clippy
Diffstat (limited to 'crates/vcs')
-rw-r--r--crates/vcs/src/data/sheet.rs2
-rw-r--r--crates/vcs/src/data/vault/sheets.rs12
2 files changed, 6 insertions, 8 deletions
diff --git a/crates/vcs/src/data/sheet.rs b/crates/vcs/src/data/sheet.rs
index 17a0981..edf307a 100644
--- a/crates/vcs/src/data/sheet.rs
+++ b/crates/vcs/src/data/sheet.rs
@@ -102,7 +102,7 @@ impl<'a> Sheet<'a> {
/// Because I don't want a second instance of the sheet to be kept in memory.
/// If needed, please deserialize and reload it.
pub async fn persist(self) -> Result<(), std::io::Error> {
- SheetData::write_to(&self.data, &self.sheet_path()).await
+ SheetData::write_to(&self.data, self.sheet_path()).await
}
/// Get the path to the sheet file
diff --git a/crates/vcs/src/data/vault/sheets.rs b/crates/vcs/src/data/vault/sheets.rs
index f7f6665..dfad862 100644
--- a/crates/vcs/src/data/vault/sheets.rs
+++ b/crates/vcs/src/data/vault/sheets.rs
@@ -53,12 +53,11 @@ impl Vault {
let path = entry.path();
// Check if it's a YAML file
- if path.is_file() && path.extension().map_or(false, |ext| ext == "yaml") {
- if let Some(file_stem) = path.file_stem().and_then(|s| s.to_str()) {
+ if path.is_file() && path.extension().is_some_and(|ext| ext == "yaml")
+ && let Some(file_stem) = path.file_stem().and_then(|s| s.to_str()) {
// Create a new SheetName and add it to the result list
sheet_names.push(file_stem.to_string());
}
- }
}
Ok(sheet_names)
@@ -220,7 +219,7 @@ impl Vault {
if !trash_dir.exists() {
return Err(Error::new(
std::io::ErrorKind::NotFound,
- format!("Trash directory does not exist!"),
+ "Trash directory does not exist!".to_string(),
));
}
@@ -229,15 +228,14 @@ impl Vault {
let entry = entry?;
let path = entry.path();
- if path.is_file() {
- if let Some(file_name) = path.file_stem().and_then(|s| s.to_str()) {
+ if path.is_file()
+ && let Some(file_name) = path.file_stem().and_then(|s| s.to_str()) {
// Check if the filename starts with the sheet name
if file_name.starts_with(&sheet_name) {
found_path = Some(path);
break;
}
}
- }
}
let trash_path = found_path.ok_or_else(|| {