@@ -355,8 +355,8 @@ impl<T: ?Sized> *const T {
355355 ///
356356 /// If any of the following conditions are violated, the result is Undefined Behavior:
357357 ///
358- /// * The computed offset, `count * size_of::<T>()` bytes (using unbounded arithmetic),
359- /// must fit in an `isize`.
358+ /// * The offset in bytes , `count * size_of::<T>()`, computed on mathematical integers (without
359+ /// "wrapping around"), must fit in an `isize`.
360360 ///
361361 /// * If the computed offset is non-zero, then `self` must be derived from a pointer to some
362362 /// [allocated object], and the entire memory range between `self` and the result must be in
@@ -399,7 +399,7 @@ impl<T: ?Sized> *const T {
399399 unsafe { intrinsics:: offset ( self , count) }
400400 }
401401
402- /// Calculates the offset from a pointer in bytes .
402+ /// Adds a signed offset in bytes to a pointer .
403403 ///
404404 /// `count` is in units of **bytes**.
405405 ///
@@ -810,15 +810,19 @@ impl<T: ?Sized> *const T {
810810
811811 /// Adds an offset to a pointer.
812812 ///
813+ /// This can only move the pointer forward (or not move it). If you need to move forward or
814+ /// backward depending on the value, then you might want [`offset`](#method.offset) instead
815+ /// which takes a signed offset.
816+ ///
813817 /// `count` is in units of T; e.g., a `count` of 3 represents a pointer
814818 /// offset of `3 * size_of::<T>()` bytes.
815819 ///
816820 /// # Safety
817821 ///
818822 /// If any of the following conditions are violated, the result is Undefined Behavior:
819823 ///
820- /// * The computed offset, `count * size_of::<T>()` bytes (using unbounded arithmetic),
821- /// must fit in an `isize`.
824+ /// * The offset in bytes , `count * size_of::<T>()`, computed on mathematical integers (without
825+ /// "wrapping around"), must fit in an `isize`.
822826 ///
823827 /// * If the computed offset is non-zero, then `self` must be derived from a pointer to some
824828 /// [allocated object], and the entire memory range between `self` and the result must be in
@@ -861,7 +865,7 @@ impl<T: ?Sized> *const T {
861865 unsafe { intrinsics:: offset ( self , count) }
862866 }
863867
864- /// Calculates the offset from a pointer in bytes (convenience for `.byte_offset(count as isize)`) .
868+ /// Adds an offset in bytes to a pointer .
865869 ///
866870 /// `count` is in units of bytes.
867871 ///
@@ -884,15 +888,19 @@ impl<T: ?Sized> *const T {
884888
885889 /// Subtracts an offset from a pointer.
886890 ///
891+ /// This can only move the pointer backward (or not move it). If you need to move forward or
892+ /// backward depending on the value, then you might want [`offset`](#method.offset) instead
893+ /// which takes a signed offset.
894+ ///
887895 /// `count` is in units of T; e.g., a `count` of 3 represents a pointer
888896 /// offset of `3 * size_of::<T>()` bytes.
889897 ///
890898 /// # Safety
891899 ///
892900 /// If any of the following conditions are violated, the result is Undefined Behavior:
893901 ///
894- /// * The computed offset, `count * size_of::<T>()` bytes (using unbounded arithmetic),
895- /// must fit in an `isize`.
902+ /// * The offset in bytes , `count * size_of::<T>()`, computed on mathematical integers (without
903+ /// "wrapping around"), must fit in an `isize`.
896904 ///
897905 /// * If the computed offset is non-zero, then `self` must be derived from a pointer to some
898906 /// [allocated object], and the entire memory range between `self` and the result must be in
@@ -943,8 +951,7 @@ impl<T: ?Sized> *const T {
943951 }
944952 }
945953
946- /// Calculates the offset from a pointer in bytes (convenience for
947- /// `.byte_offset((count as isize).wrapping_neg())`).
954+ /// Subtracts an offset in bytes from a pointer.
948955 ///
949956 /// `count` is in units of bytes.
950957 ///
0 commit comments