Skip to content

Commit f8893ed

Browse files
committed
auto merge of #12420 : pnkfelix/rust/fsk-improve-doc-for-ptr-offset, r=alexcrichton
ptr::RawPtr, spell out units used for the `offset` argument. spell out units used for the `offset` argument, so that callers do not try to scale to byte units themselves. (this was originally landed in PR #11002 for the stand-alone functions, but that PR did not modify the `RawPtr` methods, since that had no doc at all at the time. Now `RawPtr` has the *only* documentation for `offset`, since the stand-alone functions went away in PR #12167 / PR #12248.)
2 parents c6aaf2c + e2f99b9 commit f8893ed

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libstd/ptr.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ pub trait RawPtr<T> {
213213
/// be pointing to invalid memory.
214214
unsafe fn to_option(&self) -> Option<&T>;
215215
/// Calculates the offset from a pointer. The offset *must* be in-bounds of
216-
/// the object, or one-byte-past-the-end.
216+
/// the object, or one-byte-past-the-end. `count` is in units of T; e.g. a
217+
/// `count` of 3 represents a pointer offset of `3 * sizeof::<T>()` bytes.
217218
unsafe fn offset(self, count: int) -> Self;
218219
}
219220

0 commit comments

Comments
 (0)