diff options
Diffstat (limited to 'common/object/src/value.rs')
| -rw-r--r-- | common/object/src/value.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/common/object/src/value.rs b/common/object/src/value.rs index 0a1ceb9..ace10fe 100644 --- a/common/object/src/value.rs +++ b/common/object/src/value.rs @@ -73,10 +73,7 @@ pub enum ValueType { impl ValueType { #[inline] pub const fn is_aligned(self) -> bool { - match self { - ValueType::Binary | ValueType::String => false, - _ => true, - } + !matches!(self, ValueType::Binary | ValueType::String) } pub fn from_num(n: u32) -> Self { match n { @@ -180,7 +177,7 @@ impl<'a> ValueSer<'a> for &'a str { impl ValueSer<'_> for u32 { const TYPE: ValueType = ValueType::UInt; fn load_aligned(buf: &[u32]) -> Option<Self> { - buf.get(0).copied().map(u32::from_be) + buf.first().copied().map(u32::from_be) } fn store_aligned(&self, buf: &mut Vec<u32>) { buf.push(self.to_be()); @@ -192,7 +189,7 @@ impl ValueSer<'_> for u32 { impl ValueSer<'_> for Tag { const TYPE: ValueType = ValueType::Tag; fn load_aligned(buf: &[u32]) -> Option<Self> { - buf.get(0).copied().map(u32::from_be).map(Tag) + buf.first().copied().map(u32::from_be).map(Tag) } fn store_aligned(&self, buf: &mut Vec<u32>) { buf.push(self.0.to_be()); @@ -203,6 +200,7 @@ impl ValueSer<'_> for Tag { } impl ValueSer<'_> for u64 { const TYPE: ValueType = ValueType::UInt; + #[allow(clippy::get_first)] fn load_aligned(buf: &[u32]) -> Option<Self> { let hi = u32::from_be(*buf.get(0)?) as u64; let lo = u32::from_be(*buf.get(1)?) as u64; @@ -259,7 +257,7 @@ impl<'a> ValueSer<'a> for &'a Object { buf.extend(&self.0); } fn size(&self) -> usize { - self.0.len() * size_of::<u32>() + std::mem::size_of_val(&self.0) } } impl<'a> ValueSer<'a> for &'a [u8] { |