diff --git a/src/cachepadded.rs b/src/cachepadded.rs index 52cf323..3c14eb2 100644 --- a/src/cachepadded.rs +++ b/src/cachepadded.rs @@ -146,9 +146,7 @@ use core::ops::{Deref, DerefMut}; )), repr(align(64)) )] -pub struct CachePadded { - value: T, -} +pub struct CachePadded(pub T); unsafe impl Send for CachePadded {} unsafe impl Sync for CachePadded {} @@ -164,7 +162,7 @@ impl CachePadded { /// let padded_value = CachePadded::new(1); /// ``` pub const fn new(t: T) -> CachePadded { - CachePadded:: { value: t } + CachePadded::(t) } /// Returns the inner value. @@ -179,7 +177,7 @@ impl CachePadded { /// assert_eq!(value, 7); /// ``` pub fn into_inner(self) -> T { - self.value + self.0 } } @@ -187,20 +185,20 @@ impl Deref for CachePadded { type Target = T; fn deref(&self) -> &T { - &self.value + &self.0 } } impl DerefMut for CachePadded { fn deref_mut(&mut self) -> &mut T { - &mut self.value + &mut self.0 } } impl fmt::Debug for CachePadded { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("CachePadded") - .field("value", &self.value) + .field("value", &self.0) .finish() } } @@ -213,6 +211,6 @@ impl From for CachePadded { impl fmt::Display for CachePadded { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Display::fmt(&self.value, f) + fmt::Display::fmt(&self.0, f) } }