#[repr(C)]pub struct Aligned<T: ?Sized, const ALIGNMENT: usize>where
Alignment<ALIGNMENT>: SupportedAlignment,{
pub align: AlignedZst<ALIGNMENT>,
pub inner: T,
}
Expand description
A wrapper type with the specified alignment.
This type implements most relevant traits if the wrapped type does,
including Default
, Ord
, Copy
, Send
, Sync
, Unpin
,
etc.
With the bytemuck
optional feature enabled, this type implements the
bytemuck::AnyBitPattern
trait if the wrapped type does. (It cannot in general implement Pod
,
because there may be padding.)
With the freeze
optional feature enabled, this type implements the
unstable core::marker::Freeze
trait if the wrapped type does.
§Layout
The wrapped field inner
is at offset 0
, and the size and alignment of
Self
are minimal to meet the wrapped field’s size and alignment, and to
meet the requested alignment, under Rust’s normal size % align == 0
rule.
This is not repr(transparent)
.
Fields§
§align: AlignedZst<ALIGNMENT>
§inner: T
Implementations§
Source§impl<T, const ALIGNMENT: usize> Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
impl<T, const ALIGNMENT: usize> Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes this Aligned
wrapper, returning the wrapped value.
Trait Implementations§
Source§impl<T: ?Sized, const ALIGNMENT: usize> AsMut<T> for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
impl<T: ?Sized, const ALIGNMENT: usize> AsMut<T> for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
Source§impl<T: ?Sized, const ALIGNMENT: usize> AsRef<T> for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
impl<T: ?Sized, const ALIGNMENT: usize> AsRef<T> for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
Source§impl<T: ?Sized, const ALIGNMENT: usize> Borrow<T> for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
impl<T: ?Sized, const ALIGNMENT: usize> Borrow<T> for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
Source§impl<T: ?Sized, const ALIGNMENT: usize> BorrowMut<T> for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
impl<T: ?Sized, const ALIGNMENT: usize> BorrowMut<T> for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T: Clone + ?Sized, const ALIGNMENT: usize> Clone for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
impl<T: Clone + ?Sized, const ALIGNMENT: usize> Clone for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
Source§impl<T: Default + ?Sized, const ALIGNMENT: usize> Default for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
impl<T: Default + ?Sized, const ALIGNMENT: usize> Default for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
Source§impl<T: ?Sized + Hash, const ALIGNMENT: usize> Hash for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
impl<T: ?Sized + Hash, const ALIGNMENT: usize> Hash for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
Source§impl<T: Ord + ?Sized, const ALIGNMENT: usize> Ord for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
impl<T: Ord + ?Sized, const ALIGNMENT: usize> Ord for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T: PartialEq + ?Sized, const ALIGNMENT: usize> PartialEq for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
impl<T: PartialEq + ?Sized, const ALIGNMENT: usize> PartialEq for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
Source§impl<T: PartialOrd + ?Sized, const ALIGNMENT: usize> PartialOrd for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
impl<T: PartialOrd + ?Sized, const ALIGNMENT: usize> PartialOrd for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
Source§impl<T, const ALIGNMENT: usize> Zeroable for Aligned<T, ALIGNMENT>
Available on crate feature bytemuck
only.
impl<T, const ALIGNMENT: usize> Zeroable for Aligned<T, ALIGNMENT>
bytemuck
only.impl<T, const ALIGNMENT: usize> AnyBitPattern for Aligned<T, ALIGNMENT>
bytemuck
only.impl<T: Copy + ?Sized, const ALIGNMENT: usize> Copy for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
impl<T: Eq + ?Sized, const ALIGNMENT: usize> Eq for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
impl<T: ?Sized, const ALIGNMENT: usize> StructuralPartialEq for Aligned<T, ALIGNMENT>where
Alignment<ALIGNMENT>: SupportedAlignment,
Auto Trait Implementations§
impl<T, const ALIGNMENT: usize> Freeze for Aligned<T, ALIGNMENT>
impl<T, const ALIGNMENT: usize> RefUnwindSafe for Aligned<T, ALIGNMENT>where
T: RefUnwindSafe + ?Sized,
impl<T, const ALIGNMENT: usize> Send for Aligned<T, ALIGNMENT>
impl<T, const ALIGNMENT: usize> Sync for Aligned<T, ALIGNMENT>
impl<T, const ALIGNMENT: usize> Unpin for Aligned<T, ALIGNMENT>
impl<T, const ALIGNMENT: usize> UnwindSafe for Aligned<T, ALIGNMENT>where
T: UnwindSafe + ?Sized,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self
.