From 6c1ebff59e5c92eadd1ed5d986c36e34791d6ed3 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Fri, 15 Apr 2022 01:58:59 +0400 Subject: [PATCH] Implement `ptr.is_aligned()` in terms of `.is_aligned_to()` --- library/core/src/ptr/const_ptr.rs | 2 +- library/core/src/ptr/mut_ptr.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index 0d936eacc51..9bbdfd1cbb5 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -1301,7 +1301,7 @@ impl *const T { where T: Sized, { - self.addr() % core::mem::align_of::() == 0 + self.is_aligned_to(core::mem::align_of::()) } /// Returns whether the pointer is aligned to `align`. diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index d223d76ac3a..21220e2a486 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -1570,7 +1570,7 @@ impl *mut T { where T: Sized, { - self.addr() % core::mem::align_of::() == 0 + self.is_aligned_to(core::mem::align_of::()) } /// Returns whether the pointer is aligned to `align`.