Skip to content

Tracking Issue for ptr::Alignment type #102070

@scottmcm

Description

@scottmcm
Member

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

Unresolved Questions

  • Is the mask method (from impl more traits for ptr::Alignment, add mask method #115249) correct? Should it be !(a - 1) or a - 1? Should it have a different name to distinguish it more from <*const _>::mask?

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

Activity

added
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
on Sep 20, 2022
added a commit that references this issue on Oct 9, 2022
c4187f2
added a commit that references this issue on Oct 9, 2022
38db483
added 2 commits that reference this issue on Oct 10, 2022
4d5b4a8
6d35efe
added 2 commits that reference this issue on Nov 12, 2022
ac21592
f48dba1
kupiakos

kupiakos commented on Jul 22, 2023

@kupiakos
Contributor

I've been able to take advantage of an alignment newtype for performance in an embedded arena library and would find this useful to be stabilized. Are there any blockers for an FCP?

15 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Gnurou@m-ou-se@ojeda@kupiakos@clarfonthey

        Issue actions

          Tracking Issue for `ptr::Alignment` type · Issue #102070 · rust-lang/rust