Skip to content

Commit e055e60

Browse files
committed
Make some docs nicer wrt pointer offsets
1 parent e3ee9af commit e055e60

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

library/alloc/src/ffi/c_str.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,9 @@ impl CString {
436436
///
437437
/// unsafe {
438438
/// assert_eq!(b'f', *ptr as u8);
439-
/// assert_eq!(b'o', *ptr.offset(1) as u8);
440-
/// assert_eq!(b'o', *ptr.offset(2) as u8);
441-
/// assert_eq!(b'\0', *ptr.offset(3) as u8);
439+
/// assert_eq!(b'o', *ptr.add(1) as u8);
440+
/// assert_eq!(b'o', *ptr.add(2) as u8);
441+
/// assert_eq!(b'\0', *ptr.add(3) as u8);
442442
///
443443
/// // retake pointer to free memory
444444
/// let _ = CString::from_raw(ptr);

library/core/src/slice/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2905,7 +2905,7 @@ impl<T> [T] {
29052905
// `prev_ptr_write` is never less than 0 and is inside the slice.
29062906
// This fulfils the requirements for dereferencing `ptr_read`, `prev_ptr_write`
29072907
// and `ptr_write`, and for using `ptr.add(next_read)`, `ptr.add(next_write - 1)`
2908-
// and `prev_ptr_write.offset(1)`.
2908+
// and `prev_ptr_write.add(1)`.
29092909
//
29102910
// `next_write` is also incremented at most once per loop at most meaning
29112911
// no element is skipped when it may need to be swapped.

library/core/src/sync/atomic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,7 @@ impl<T> AtomicPtr<T> {
15551555
/// previous pointer.
15561556
///
15571557
/// This is equivalent to using [`wrapping_add`] and [`cast`] to atomically
1558-
/// perform `ptr = ptr.cast::<u8>().wrapping_add(val).cast::<T>()`.
1558+
/// perform `ptr = ptr.wrapping_byte_add(val)`.
15591559
///
15601560
/// `fetch_byte_add` takes an [`Ordering`] argument which describes the
15611561
/// memory ordering of this operation. All ordering modes are possible. Note
@@ -1592,7 +1592,7 @@ impl<T> AtomicPtr<T> {
15921592
/// previous pointer.
15931593
///
15941594
/// This is equivalent to using [`wrapping_sub`] and [`cast`] to atomically
1595-
/// perform `ptr = ptr.cast::<u8>().wrapping_sub(val).cast::<T>()`.
1595+
/// perform `ptr = ptr.wrapping_byte_sub(val)`.
15961596
///
15971597
/// `fetch_byte_sub` takes an [`Ordering`] argument which describes the
15981598
/// memory ordering of this operation. All ordering modes are possible. Note

0 commit comments

Comments
 (0)