File tree 2 files changed +14
-0
lines changed
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 {
611
611
/// except that it has a lot more opportunities for UB, in exchange for the compiler
612
612
/// better understanding what you are doing.
613
613
///
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
+ ///
614
621
/// [`offset`]: #method.offset
615
622
///
616
623
/// # Safety
Original file line number Diff line number Diff line change @@ -785,6 +785,13 @@ impl<T: ?Sized> *mut T {
785
785
/// except that it has a lot more opportunities for UB, in exchange for the compiler
786
786
/// better understanding what you are doing.
787
787
///
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
+ ///
788
795
/// [`offset`]: pointer#method.offset-1
789
796
///
790
797
/// # Safety
You can’t perform that action at this time.
0 commit comments