From 390da76f684221a3bb755da0a2bfa55449dca6e8 Mon Sep 17 00:00:00 2001 From: weisd Date: Tue, 3 Dec 2024 13:37:22 +0800 Subject: [PATCH] fix clippy --- ecstore/src/bitrot.rs | 13 +++++++------ ecstore/src/file_meta.rs | 27 +++++++++++++++++---------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/ecstore/src/bitrot.rs b/ecstore/src/bitrot.rs index 738fed60..e26d039b 100644 --- a/ecstore/src/bitrot.rs +++ b/ecstore/src/bitrot.rs @@ -169,6 +169,7 @@ pub async fn new_bitrot_writer( pub type BitrotReader = Box; +#[allow(clippy::too_many_arguments)] pub fn new_bitrot_reader( disk: DiskStore, data: &[u8], @@ -691,16 +692,16 @@ mod test { let ep = Endpoint::try_from(temp_dir.as_str())?; let opt = DiskOption::default(); let disk = new_disk(&ep, &opt).await?; - let _ = disk.make_volume(volume).await?; + disk.make_volume(volume).await?; let mut writer = new_bitrot_writer(disk.clone(), "", volume, file_path, 35, algo.clone(), 10).await?; - let _ = writer.write(b"aaaaaaaaaa").await?; - let _ = writer.write(b"aaaaaaaaaa").await?; - let _ = writer.write(b"aaaaaaaaaa").await?; - let _ = writer.write(b"aaaaa").await?; + writer.write(b"aaaaaaaaaa").await?; + writer.write(b"aaaaaaaaaa").await?; + writer.write(b"aaaaaaaaaa").await?; + writer.write(b"aaaaa").await?; let sum = bitrot_writer_sum(&writer); - let _ = writer.close().await?; + writer.close().await?; let mut reader = new_bitrot_reader(disk, b"", volume, file_path, 35, algo, &sum, 10); let read_len = 10; diff --git a/ecstore/src/file_meta.rs b/ecstore/src/file_meta.rs index 3a774289..d506e3ef 100644 --- a/ecstore/src/file_meta.rs +++ b/ecstore/src/file_meta.rs @@ -824,7 +824,7 @@ impl TryFrom for FileMetaVersion { } } -#[derive(Serialize, Deserialize, Debug, PartialEq, Default, Clone, Eq, Ord, Hash)] +#[derive(Serialize, Deserialize, Debug, PartialEq, Default, Clone, Eq, Hash)] pub struct FileMetaVersionHeader { pub version_id: Option, pub mod_time: Option, @@ -974,26 +974,33 @@ impl FileMetaVersionHeader { impl PartialOrd for FileMetaVersionHeader { fn partial_cmp(&self, other: &Self) -> Option { - match self.mod_time.partial_cmp(&other.mod_time) { - Some(core::cmp::Ordering::Equal) => {} + Some(self.cmp(other)) + } +} + +impl Ord for FileMetaVersionHeader { + fn cmp(&self, other: &Self) -> Ordering { + match self.mod_time.cmp(&other.mod_time) { + core::cmp::Ordering::Equal => {} ord => return ord, } - match self.version_type.partial_cmp(&other.version_type) { - Some(core::cmp::Ordering::Equal) => {} + match self.version_type.cmp(&other.version_type) { + core::cmp::Ordering::Equal => {} ord => return ord, } - match self.signature.partial_cmp(&other.signature) { - Some(core::cmp::Ordering::Equal) => {} + match self.signature.cmp(&other.signature) { + core::cmp::Ordering::Equal => {} ord => return ord, } - match self.version_id.partial_cmp(&other.version_id) { - Some(core::cmp::Ordering::Equal) => {} + match self.version_id.cmp(&other.version_id) { + core::cmp::Ordering::Equal => {} ord => return ord, } - self.flags.partial_cmp(&other.flags) + self.flags.cmp(&other.flags) } } + impl From for FileMetaVersionHeader { fn from(value: FileMetaVersion) -> Self { let flags = {