Skip to content

Commit f29327f

Browse files
committed
Clarify that align_offset overaligns
The current documentation is not clear whether adding `a` to a pointer overaligns (align up) or underaligns (align down). It should say this explicitly.
1 parent b2dd217 commit f29327f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

library/core/src/ptr/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,10 +2166,9 @@ pub unsafe fn write_volatile<T>(dst: *mut T, src: T) {
21662166
}
21672167
}
21682168

2169-
/// Align pointer `p`.
2169+
/// Calculate an element-offset that increases a pointer's alignment.
21702170
///
2171-
/// Calculate offset (in terms of elements of `size_of::<T>()` stride) that has to be applied
2172-
/// to pointer `p` so that pointer `p` would get aligned to `a`.
2171+
/// Calculate an element-offset (not byte-offset) that when added to a given pointer `p`, increases `p`'s alignment to at least the given alignment `a`.
21732172
///
21742173
/// # Safety
21752174
/// `a` must be a power of two.

0 commit comments

Comments
 (0)