File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -611,6 +611,13 @@ impl<T: ?Sized> *const T {
611611 /// except that it has a lot more opportunities for UB, in exchange for the compiler
612612 /// better understanding what you are doing.
613613 ///
614+ /// The primary motivation of this method is for computing the `len` of an array/slice
615+ /// of `T` that you are currently representing as a "start" and "end" pointer
616+ /// (and "end" is "one past the end" of the array).
617+ /// In that case, `end.offset_from(start)` gets you the length of the array.
618+ ///
619+ /// All of the following safety requirements are trivially satisfied for this usecase.
620+ ///
614621 /// [`offset`]: #method.offset
615622 ///
616623 /// # Safety
Original file line number Diff line number Diff line change @@ -785,6 +785,13 @@ impl<T: ?Sized> *mut T {
785785 /// except that it has a lot more opportunities for UB, in exchange for the compiler
786786 /// better understanding what you are doing.
787787 ///
788+ /// The primary motivation of this method is for computing the `len` of an array/slice
789+ /// of `T` that you are currently representing as a "start" and "end" pointer
790+ /// (and "end" is "one past the end" of the array).
791+ /// In that case, `end.offset_from(start)` gets you the length of the array.
792+ ///
793+ /// All of the following safety requirements are trivially satisfied for this usecase.
794+ ///
788795 /// [`offset`]: pointer#method.offset-1
789796 ///
790797 /// # Safety
You can’t perform that action at this time.
0 commit comments