mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-07-22 01:46:44 +08:00
refactor: reduce quality findings
This commit is contained in:
@@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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?;
|
||||
/// ```
|
||||
///
|
||||
/// # 实现建议
|
||||
|
||||
Reference in New Issue
Block a user