Tracking Issue for ptr::Alignment
type · Issue #102070 · rust-lang/rust (original) (raw)
Feature gate: #![feature(ptr_alignment_type)]
This is a tracking issue for the ptr::Alignment type, and related methods, to represent values that are valid alignments in the rust abstract machine.
Public API
// core::ptr
#[derive(Copy, Clone, Eq, PartialEq)] pub struct Alignment(…);
impl Debug for Alignment; impl Ord for Alignment; impl PartialOrd for Alignment; impl Hash for Alignment;
impl Alignment { pub const MIN: Self; pub const fn of() -> Self; pub const fn new(align: usize) -> Option; pub const unsafe fn new_unchecked(align: usize) -> Self; pub const fn as_usize(self) -> usize; pub const fn as_nonzero(self) -> NonZeroUsize; pub const fn log2(self) -> u32; }
impl TryFrom for Alignment; impl TryFrom for Alignment; impl From for NonZeroUsize; impl From for usize;
Steps / History
- ACP Add a specific type for pointer alignment libs-team#108
- Implementation: Add ptr::Alignment type #102072
- From for usize & NonZeroUsize #102862
- Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- Is the
mask
method (from impl more traits for ptr::Alignment, add mask method #115249) correct? Should it be!(a - 1)
ora - 1
? Should it have a different name to distinguish it more from<*const _>::mask
?