Open
Description
opened on Sep 20, 2022
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<T>() -> Self;
pub const fn new(align: usize) -> Option<Self>;
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<NonZeroUsize> for Alignment;
impl TryFrom<usize> for Alignment;
impl From<Alignment> for NonZeroUsize;
impl From<Alignment> for usize;
Steps / History
- ACP Add a specific type for pointer alignment libs-team#108
- Implementation: Add
ptr::Alignment
type #102072 - From<Alignment> 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
?
Activity