pub struct MemoryAlignment;Expand description
Memory alignment utilities
Implementations§
Source§impl MemoryAlignment
impl MemoryAlignment
Sourcepub fn is_aligned<T>(ptr: *const T, alignment: usize) -> bool
pub fn is_aligned<T>(ptr: *const T, alignment: usize) -> bool
Check if a pointer is aligned to the specified boundary
Sourcepub fn alignment_of<T>() -> usize
pub fn alignment_of<T>() -> usize
Get the alignment of a type
Sourcepub fn aligned_size(size: usize, alignment: usize) -> usize
pub fn aligned_size(size: usize, alignment: usize) -> usize
Calculate aligned size
Sourcepub fn aligned_layout(
size: usize,
alignment: usize,
) -> Result<Layout, LayoutError>
pub fn aligned_layout( size: usize, alignment: usize, ) -> Result<Layout, LayoutError>
Create aligned memory layout
Auto Trait Implementations§
impl Freeze for MemoryAlignment
impl RefUnwindSafe for MemoryAlignment
impl Send for MemoryAlignment
impl Sync for MemoryAlignment
impl Unpin for MemoryAlignment
impl UnwindSafe for MemoryAlignment
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
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more