Skip to content

Commit 9a12d9a

Browse files
committed
fix dead links to wrapping_offset_from
1 parent 4f92f0d commit 9a12d9a

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

library/core/src/ptr/const_ptr.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ impl<T: ?Sized> *const T {
240240
/// different allocated object. Note that in Rust,
241241
/// every (stack-allocated) variable is considered a separate allocated object.
242242
///
243-
/// In other words, `x.wrapping_offset(y.wrapping_offset_from(x))` is
244-
/// *not* the same as `y`, and dereferencing it is undefined behavior
243+
/// In other words, `x.wrapping_offset((y as usize).wrapping_sub(x as usize) / size_of::<T>())`
244+
/// is *not* the same as `y`, and dereferencing it is undefined behavior
245245
/// unless `x` and `y` point into the same allocated object.
246246
///
247247
/// Compared to [`offset`], this method basically delays the requirement of staying
@@ -292,7 +292,6 @@ impl<T: ?Sized> *const T {
292292
/// This function is the inverse of [`offset`].
293293
///
294294
/// [`offset`]: #method.offset
295-
/// [`wrapping_offset_from`]: #method.wrapping_offset_from
296295
///
297296
/// # Safety
298297
///
@@ -326,10 +325,6 @@ impl<T: ?Sized> *const T {
326325
/// Extension. As such, memory acquired directly from allocators or memory
327326
/// mapped files *may* be too large to handle with this function.
328327
///
329-
/// Consider using [`wrapping_offset_from`] instead if these constraints are
330-
/// difficult to satisfy. The only advantage of this method is that it
331-
/// enables more aggressive compiler optimizations.
332-
///
333328
/// # Panics
334329
///
335330
/// This function panics if `T` is a Zero-Sized Type ("ZST").

library/core/src/ptr/mut_ptr.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ impl<T: ?Sized> *mut T {
246246
/// different allocated object. Note that in Rust,
247247
/// every (stack-allocated) variable is considered a separate allocated object.
248248
///
249-
/// In other words, `x.wrapping_offset(y.wrapping_offset_from(x))` is
250-
/// *not* the same as `y`, and dereferencing it is undefined behavior
249+
/// In other words, `x.wrapping_offset((y as usize).wrapping_sub(x as usize) / size_of::<T>())`
250+
/// is *not* the same as `y`, and dereferencing it is undefined behavior
251251
/// unless `x` and `y` point into the same allocated object.
252252
///
253253
/// Compared to [`offset`], this method basically delays the requirement of staying
@@ -463,7 +463,6 @@ impl<T: ?Sized> *mut T {
463463
/// This function is the inverse of [`offset`].
464464
///
465465
/// [`offset`]: #method.offset-1
466-
/// [`wrapping_offset_from`]: #method.wrapping_offset_from-1
467466
///
468467
/// # Safety
469468
///
@@ -497,10 +496,6 @@ impl<T: ?Sized> *mut T {
497496
/// Extension. As such, memory acquired directly from allocators or memory
498497
/// mapped files *may* be too large to handle with this function.
499498
///
500-
/// Consider using [`wrapping_offset_from`] instead if these constraints are
501-
/// difficult to satisfy. The only advantage of this method is that it
502-
/// enables more aggressive compiler optimizations.
503-
///
504499
/// # Panics
505500
///
506501
/// This function panics if `T` is a Zero-Sized Type ("ZST").

0 commit comments

Comments
 (0)