pub struct Alignment(/* private fields */);Expand description
A valid Layout alignment (a power of 2)
Available in named constant forms, which have been #[doc(hidden)] to avoid spam:
| Min | Max | Name | Equivalences |
|---|---|---|---|
ALIGN_1 | ALIGN_8192 | Byte(s) | 8 bits = 1 octect ≈ 1 byte |
ALIGN_1_B | ALIGN_8192_B | Byte(s) | 8 bits = 1 octect ≈ 1 byte |
ALIGN_1_KiB | ALIGN_8192_KiB | Kibibyte(s) | 1 KiB = 210 bytes = 10241 bytes |
ALIGN_1_MiB | ALIGN_8192_MiB | Mebibyte(s) | 1 MiB = 220 bytes = 10242 bytes |
ALIGN_1_GiB | ALIGN_8192_GiB | Gibibyte(s) | 1 GiB = 230 bytes = 10243 bytes |
ALIGN_1_TiB | ALIGN_8192_TiB | Tebibyte(s) | 1 TiB = 240 bytes = 10244 bytes |
ALIGN_1_EiB | ALIGN_8192_EiB | Exbibyte(s) | 1 EiB = 250 bytes = 10245 bytes |
Implementations§
Source§impl Alignment
impl Alignment
Sourcepub const MAX: Alignment
pub const MAX: Alignment
Maximum representable alignment
| Bits | MAX |
|---|---|
| 16 | 215 B = 32 KiB |
| 32 | 231 B = 2 GiB |
| 64 | 263 B = 8 EiB |
| 128 | 2127 B = ??? |
Sourcepub const fn new(align: usize) -> Option<Self>
pub const fn new(align: usize) -> Option<Self>
Returns None unless align is a valid power of 2 (which also implies nonzero)
Sourcepub const unsafe fn new_unchecked(align: usize) -> Self
pub const unsafe fn new_unchecked(align: usize) -> Self
Undefined behavior unless align is a valid power of 2 (which also implies nonzero)
Sourcepub const fn as_usize(self) -> usize
pub const fn as_usize(self) -> usize
Returns the alignment as a usize (the nicheless underlying type)
Sourcepub const fn as_nonzero(self) -> NonZeroUsize
pub const fn as_nonzero(self) -> NonZeroUsize
Returns the alignment as a NonZeroUsize
Trait Implementations§
Source§impl From<Alignment> for NonZeroUsize
impl From<Alignment> for NonZeroUsize
Source§impl Ord for Alignment
impl Ord for Alignment
Source§impl PartialOrd for Alignment
impl PartialOrd for Alignment
Source§impl TryFrom<NonZero<usize>> for Alignment
impl TryFrom<NonZero<usize>> for Alignment
Source§type Error = TryFromIntError
type Error = TryFromIntError
The type returned in the event of a conversion error.
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