From 9c44621f13f27e7f2a82fa5ab2fc8e27381f3e39 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Fri, 26 Sep 2025 11:18:08 +0800 Subject: Fixed by clippy --- crates/vcs/src/data/sheet.rs | 2 +- crates/vcs/src/data/vault/sheets.rs | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'crates/vcs') 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(|| { -- cgit