Feature gate: #![feature(const_pointer_is_aligned)]
This is a tracking issue for using ptr.is_aligned() and ptr.is_aligned_to(alignment) in const contexts.
Public API
impl<T: Sized> *(const|mut) T {
pub const fn is_aligned(self) -> bool;
}
impl<T: ?Sized> *(const|mut) T {
pub const fn is_aligned_to(self, align: usize) -> bool;
}
impl <T> NonNull<T> {
pub const fn is_aligned(self) -> bool;
}
Steps / History
Unresolved Questions
Related Links
Feature gate:
#![feature(const_pointer_is_aligned)]This is a tracking issue for using
ptr.is_aligned()andptr.is_aligned_to(alignment)inconstcontexts.Public API
Steps / History
is_alignedviaalign_offset#102795NonNullmethods stabilized,constness moved to this gate Stabilizenon_null_convenience#124498constfunctions to behave differently during constant-evaluation and runtime: Relax const-eval restrictions rfcs#3352Unresolved Questions
guaranteed_aligned{,to}instead?trueif the pointer is guaranteed to be aligned at runtime andfalseif we don't know whether the pointer is aligned at runtime. This is the current implementation.align_offset. This allows changes to const alignment in the future.Related Links
is_aligned: Tracking Issue for pointer_is_aligned_to #96284align_offset: Tracking Issue forconst_align_offset#90962Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩