pub struct Alignment(/* private fields */);
Expand description
usize
that’s guaranteed to be a power of two (excluding zero).
Implementations§
Source§impl Alignment
impl Alignment
Sourcepub const unsafe fn new_unchecked(len: usize) -> Alignment
pub const unsafe fn new_unchecked(len: usize) -> Alignment
Converts a usize
into a DoubledLen
without checking for validity.
§Safety
Caller must ensure that the given length is a power of two.
Sourcepub const fn as_nonzero(self) -> NonZeroUsize
pub const fn as_nonzero(self) -> NonZeroUsize
Converts to a NonZeroUsize
.
Sourcepub const fn as_len(self) -> DoubledLen
pub const fn as_len(self) -> DoubledLen
Converts to a DoubledLen
.
Trait Implementations§
Source§impl From<Alignment> for DoubledLen
impl From<Alignment> for DoubledLen
Source§fn from(align: Alignment) -> DoubledLen
fn from(align: Alignment) -> DoubledLen
Converts to this type from the input type.
Source§impl From<Alignment> for NonZeroUsize
impl From<Alignment> for NonZeroUsize
Source§fn from(align: Alignment) -> NonZeroUsize
fn from(align: Alignment) -> NonZeroUsize
Converts to this type from the input type.
Source§impl Ord for Alignment
impl Ord for Alignment
Source§impl PartialOrd for Alignment
impl PartialOrd for Alignment
Source§impl TryFrom<DoubledLen> for Alignment
impl TryFrom<DoubledLen> for Alignment
Source§type Error = ZeroLenError
type Error = ZeroLenError
The type returned in the event of a conversion error.
Source§fn try_from(len: DoubledLen) -> Result<Alignment, ZeroLenError>
fn try_from(len: DoubledLen) -> Result<Alignment, ZeroLenError>
Performs the conversion.
Source§impl TryFrom<NonZero<usize>> for Alignment
impl TryFrom<NonZero<usize>> for Alignment
Source§type Error = TryFromSizeError
type Error = TryFromSizeError
The type returned in the event of a conversion error.
Source§fn try_from(len: NonZeroUsize) -> Result<Alignment, TryFromSizeError>
fn try_from(len: NonZeroUsize) -> Result<Alignment, TryFromSizeError>
Performs the conversion.
impl Copy for Alignment
impl Eq for Alignment
impl StructuralPartialEq for Alignment
Auto Trait Implementations§
impl Freeze for Alignment
impl RefUnwindSafe for Alignment
impl Send for Alignment
impl Sync for Alignment
impl Unpin for Alignment
impl UnwindSafe for Alignment
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