refactor: reduce quality findings

This commit is contained in:
2026-06-28 15:42:12 +08:00
parent 02716d3ccd
commit 3c00659691
11 changed files with 189 additions and 135 deletions
+4 -4
View File
@@ -328,9 +328,8 @@ pub trait CasRepository: Send + Sync {
/// - 确保有写入权限
async fn export_to_file(&self, id: &ObjectId, path: &Path) -> crate::Result<()> {
let data = self.get(id).await?;
tokio::fs::write(path, data)
.await
.map_err(crate::Error::Io)?;
let write_result = tokio::fs::write(path, data).await.map_err(crate::Error::Io);
write_result?;
Ok(())
}
}
@@ -356,6 +355,7 @@ mod tests {
let id: ObjectId = "hash_abc123".to_string();
map.insert(id.clone(), "value");
assert_eq!(map.get(&id), Some(&"value"));
let value = map.get(&id);
assert_eq!(value, Some(&"value"));
}
}
+1 -1
View File
@@ -366,7 +366,7 @@ pub trait ResourceRepository: Send + Sync {
/// # 示例
///
/// ```rust,ignore
/// repo.delete("res_001").await?;
/// let () = repo.delete("res_001").await?;
/// ```
async fn delete(&self, id: &str) -> crate::Result<()>;
@@ -407,7 +407,7 @@ pub trait TranslationRepository: Send + Sync {
///
/// ```rust,ignore
/// // 删除错误的翻译
/// repo.delete("bad_translation_001").await?;
/// let () = repo.delete("bad_translation_001").await?;
/// ```
///
/// # 实现建议