@@ -606,9 +606,8 @@ impl<T: ?Sized> *const T {
606606 /// Calculates the distance between two pointers. The returned value is in
607607 /// units of T: the distance in bytes divided by `mem::size_of::<T>()`.
608608 ///
609- /// This function is the inverse of [`offset`]: it is valid to call if and only if
610- /// `self` could have been computed as `origin.offset(n)` for some `n`, and it will
611- /// then return that `n`.
609+ /// This function is the inverse of [`offset`]: it is valid to call and will return
610+ /// `n` if and only if `origin.offset(n)` is valid to call and will return `self`.
612611 ///
613612 /// [`offset`]: #method.offset
614613 ///
@@ -649,9 +648,10 @@ impl<T: ?Sized> *const T {
649648 ///
650649 /// The requirement for pointers to be derived from the same allocated object is primarily
651650 /// needed for `const`-compatibility: at compile-time, pointers into *different* allocated
652- /// object do not have a known distance to each other. However, the requirement also exists at
653- /// runtime, and may be exploited by optimizations. You can use `(self as usize).sub(origin as
654- /// usize) / mem::size_of::<T>()` to avoid this requirement.
651+ /// objects do not have a known distance to each other. However, the requirement also exists at
652+ /// runtime and may be exploited by optimizations. If you wish to compute the difference between
653+ /// pointers that are not guaranteed to be from the same allocation, use `(self as
654+ /// usize).sub(origin as usize) / mem::size_of::<T>()`.
655655 ///
656656 /// [`add`]: #method.add
657657 /// [allocated object]: crate::ptr#allocated-object
0 commit comments