From a4e92ed9bec1f5879eb1c20dfe281c4d25ed5f89 Mon Sep 17 00:00:00 2001 From: Igor Tolmachev Date: Sun, 23 Jun 2024 15:19:40 +0900 Subject: Improve ZipFile --- src/structs/error.rs | 6 +++--- src/structs/settings.rs | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src/structs') diff --git a/src/structs/error.rs b/src/structs/error.rs index f08c9a3..3e74e45 100644 --- a/src/structs/error.rs +++ b/src/structs/error.rs @@ -23,13 +23,13 @@ impl From for ArchiveError { impl Display for StructError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - StructError::SerializationNotSupported { type_name } => { + Self::SerializationNotSupported { type_name } => { writeln!(f, "Serialization for type '{type_name}' not supported") } - StructError::DeserializationNotSupported { type_name } => { + Self::DeserializationNotSupported { type_name } => { writeln!(f, "Deserialization for type '{type_name}' not supported") } - StructError::UnexpectedEOF => writeln!(f, "Unexpected EOF"), + Self::UnexpectedEOF => writeln!(f, "Unexpected EOF"), } } } diff --git a/src/structs/settings.rs b/src/structs/settings.rs index fce6d9e..cf71453 100644 --- a/src/structs/settings.rs +++ b/src/structs/settings.rs @@ -20,17 +20,17 @@ macro_rules! impl_byte_order { impl ByteOrder {$( pub fn $fr(&self, num: $n) -> Vec { match self { - ByteOrder::Le => num.to_le_bytes().to_vec(), - ByteOrder::Be => num.to_be_bytes().to_vec(), - ByteOrder::Ne => num.to_ne_bytes().to_vec(), + Self::Le => num.to_le_bytes().to_vec(), + Self::Be => num.to_be_bytes().to_vec(), + Self::Ne => num.to_ne_bytes().to_vec(), } } pub fn $to(&self, bytes: [u8; size_of::<$n>()]) -> $n { match self { - ByteOrder::Le => $n::from_le_bytes(bytes), - ByteOrder::Be => $n::from_be_bytes(bytes), - ByteOrder::Ne => $n::from_ne_bytes(bytes), + Self::Le => $n::from_le_bytes(bytes), + Self::Be => $n::from_be_bytes(bytes), + Self::Ne => $n::from_ne_bytes(bytes), } } )+} @@ -55,10 +55,10 @@ impl_byte_order!( impl VariantIndexType { pub fn cast(&self, num: u32, byte_order: &ByteOrder) -> Vec { match self { - VariantIndexType::U8 => byte_order.from_u8(num as u8), - VariantIndexType::U16 => byte_order.form_u16(num as u16), - VariantIndexType::U32 => byte_order.form_u32(num as u32), - VariantIndexType::U64 => byte_order.form_u64(num as u64), + Self::U8 => byte_order.from_u8(num as u8), + Self::U16 => byte_order.form_u16(num as u16), + Self::U32 => byte_order.form_u32(num), + Self::U64 => byte_order.form_u64(num as u64), } } } -- cgit v1.2.3