Tracking Issue for pointer_is_aligned_to · Issue #96284 · rust-lang/rust (original) (raw)
Feature gate: #![feature(pointer_is_aligned)]
Feature gate: #![feature(pointer_is_aligned_to)]
This is a tracking issue for ptr.is_aligned()
andptr.is_aligned_to(alignment)
.
Public API
impl *const T {
// feature gate pointer_is_aligned
was stabilized
// pub fn is_aligned(self) -> bool where T: Sized;
// feature gate pointer_is_aligned_to
pub fn is_aligned_to(self, align: usize) -> bool;
}
// ... and the same for *mut T
impl <T: ?Sized> NonNull { pub const fn is_aligned_to(self, align: usize) -> bool; }
Steps / History
pointer_is_aligned
:
- Implementation: Add convenience byte offset/check align functions to pointers #95643
- Final comment period (FCP): stabilize ptr.is_aligned, move ptr.is_aligned_to to a new feature gate #121948 (comment)
- Stabilization PR: stabilize ptr.is_aligned, move ptr.is_aligned_to to a new feature gate #121948
pointer_is_aligned_to
:
- Implementation: Add convenience byte offset/check align functions to pointers #95643 and stabilize ptr.is_aligned, move ptr.is_aligned_to to a new feature gate #121948
- Move the
NonNull
method to this gate Stabilize non_null_convenience #124498 - Final comment period (FCP)
- Stabilization PR
Unresolved Questions
- Should is_aligned_to require a power of two or should it be more flexible? (currently panics)