Skip to content

Commit 6c1ebff

Browse files
committed
Implement ptr.is_aligned() in terms of .is_aligned_to()
1 parent a908eec commit 6c1ebff

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

library/core/src/ptr/const_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ impl<T: ?Sized> *const T {
13011301
where
13021302
T: Sized,
13031303
{
1304-
self.addr() % core::mem::align_of::<T>() == 0
1304+
self.is_aligned_to(core::mem::align_of::<T>())
13051305
}
13061306

13071307
/// Returns whether the pointer is aligned to `align`.

library/core/src/ptr/mut_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,7 @@ impl<T: ?Sized> *mut T {
15701570
where
15711571
T: Sized,
15721572
{
1573-
self.addr() % core::mem::align_of::<T>() == 0
1573+
self.is_aligned_to(core::mem::align_of::<T>())
15741574
}
15751575

15761576
/// Returns whether the pointer is aligned to `align`.

0 commit comments

Comments
 (0)