From 59adf6dcf8a1adfbfbf05583866f6c5b0d85b374 Mon Sep 17 00:00:00 2001 From: hinto-janai Date: Fri, 9 Aug 2024 19:09:25 -0400 Subject: [PATCH] `std::mem::{size,align}_of` -> `{size,align}_of` (#254) --- net/epee-encoding/src/container_as_blob.rs | 2 +- net/epee-encoding/src/io.rs | 4 ++-- storage/blockchain/src/types.rs | 5 ----- storage/database/README.md | 4 ++-- storage/database/src/storable.rs | 2 +- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/net/epee-encoding/src/container_as_blob.rs b/net/epee-encoding/src/container_as_blob.rs index a4e8808..701ec66 100644 --- a/net/epee-encoding/src/container_as_blob.rs +++ b/net/epee-encoding/src/container_as_blob.rs @@ -70,7 +70,7 @@ pub trait Containerable { macro_rules! int_container_able { ($int:ty ) => { impl Containerable for $int { - const SIZE: usize = std::mem::size_of::<$int>(); + const SIZE: usize = size_of::<$int>(); fn from_bytes(bytes: &[u8]) -> Self { <$int>::from_le_bytes(bytes.try_into().unwrap()) diff --git a/net/epee-encoding/src/io.rs b/net/epee-encoding/src/io.rs index 4f4240d..110a1ec 100644 --- a/net/epee-encoding/src/io.rs +++ b/net/epee-encoding/src/io.rs @@ -7,7 +7,7 @@ pub fn checked_read_primitive( b: &mut B, read: impl Fn(&mut B) -> R, ) -> Result { - checked_read(b, read, core::mem::size_of::()) + checked_read(b, read, size_of::()) } #[inline] @@ -25,7 +25,7 @@ pub fn checked_write_primitive( write: impl Fn(&mut B, T), t: T, ) -> Result<()> { - checked_write(b, write, t, core::mem::size_of::()) + checked_write(b, write, t, size_of::()) } #[inline] diff --git a/storage/blockchain/src/types.rs b/storage/blockchain/src/types.rs index 08cde31..9abd175 100644 --- a/storage/blockchain/src/types.rs +++ b/storage/blockchain/src/types.rs @@ -121,7 +121,6 @@ pub type UnlockTime = u64; /// # Size & Alignment /// ```rust /// # use cuprate_blockchain::types::*; -/// # use std::mem::*; /// assert_eq!(size_of::(), 16); /// assert_eq!(align_of::(), 8); /// ``` @@ -174,7 +173,6 @@ impl Key for PreRctOutputId {} /// # Size & Alignment /// ```rust /// # use cuprate_blockchain::types::*; -/// # use std::mem::*; /// assert_eq!(size_of::(), 88); /// assert_eq!(align_of::(), 8); /// ``` @@ -226,7 +224,6 @@ bitflags::bitflags! { /// # Size & Alignment /// ```rust /// # use cuprate_blockchain::types::*; - /// # use std::mem::*; /// assert_eq!(size_of::(), 4); /// assert_eq!(align_of::(), 4); /// ``` @@ -262,7 +259,6 @@ bitflags::bitflags! { /// # Size & Alignment /// ```rust /// # use cuprate_blockchain::types::*; -/// # use std::mem::*; /// assert_eq!(size_of::(), 48); /// assert_eq!(align_of::(), 8); /// ``` @@ -306,7 +302,6 @@ pub struct Output { /// # Size & Alignment /// ```rust /// # use cuprate_blockchain::types::*; -/// # use std::mem::*; /// assert_eq!(size_of::(), 80); /// assert_eq!(align_of::(), 8); /// ``` diff --git a/storage/database/README.md b/storage/database/README.md index aed738e..c805ab0 100644 --- a/storage/database/README.md +++ b/storage/database/README.md @@ -66,8 +66,8 @@ As `ConcreteEnv` is just a re-exposed type which has varying inner types, it means some properties will change depending on the backend used. For example: -- [`std::mem::size_of::`] -- [`std::mem::align_of::`] +- [`size_of::`] +- [`align_of::`] Things like these functions are affected by the backend and inner data, and should not be relied upon. This extends to any `struct/enum` that contains `ConcreteEnv`. diff --git a/storage/database/src/storable.rs b/storage/database/src/storable.rs index 100ed44..b153568 100644 --- a/storage/database/src/storable.rs +++ b/storage/database/src/storable.rs @@ -109,7 +109,7 @@ impl Storable for T where Self: Pod + Debug, { - const BYTE_LENGTH: Option = Some(std::mem::size_of::()); + const BYTE_LENGTH: Option = Some(size_of::()); #[inline] fn as_bytes(&self) -> &[u8] {