@@ -781,9 +781,8 @@ impl<T: ?Sized> *mut T {
781
781
/// Calculates the distance between two pointers. The returned value is in
782
782
/// units of T: the distance in bytes divided by `mem::size_of::<T>()`.
783
783
///
784
- /// This function is the inverse of [`offset`]: it is valid to call if and only if
785
- /// `self` could have been computed as `origin.offset(n)` for some `n`, and it will
786
- /// then return that `n`.
784
+ /// This function is the inverse of [`offset`]: it is valid to call and will return
785
+ /// `n` if and only if `origin.offset(n)` is valid to call and will return `self`.
787
786
///
788
787
/// [`offset`]: pointer#method.offset-1
789
788
///
@@ -824,9 +823,10 @@ impl<T: ?Sized> *mut T {
824
823
///
825
824
/// The requirement for pointers to be derived from the same allocated object is primarily
826
825
/// needed for `const`-compatibility: at compile-time, pointers into *different* allocated
827
- /// object do not have a known distance to each other. However, the requirement also exists at
828
- /// runtime, and may be exploited by optimizations. You can use `(self as usize).sub(origin as
829
- /// usize) / mem::size_of::<T>()` to avoid this requirement.
826
+ /// objects do not have a known distance to each other. However, the requirement also exists at
827
+ /// runtime and may be exploited by optimizations. If you wish to compute the difference between
828
+ /// pointers that are not guaranteed to be from the same allocation, use `(self as
829
+ /// usize).sub(origin as usize) / mem::size_of::<T>()`.
830
830
///
831
831
/// [`add`]: #method.add
832
832
/// [allocated object]: crate::ptr#allocated-object
0 commit comments