take more clarifying text from Gankra's PR
original source: https://github.com/rust-lang/rust/pull/95851
This commit is contained in:
parent
6c73f254b9
commit
9b7f9c4328
2 changed files with 14 additions and 0 deletions
|
@ -611,6 +611,13 @@ impl<T: ?Sized> *const T {
|
|||
/// except that it has a lot more opportunities for UB, in exchange for the compiler
|
||||
/// better understanding what you are doing.
|
||||
///
|
||||
/// The primary motivation of this method is for computing the `len` of an array/slice
|
||||
/// of `T` that you are currently representing as a "start" and "end" pointer
|
||||
/// (and "end" is "one past the end" of the array).
|
||||
/// In that case, `end.offset_from(start)` gets you the length of the array.
|
||||
///
|
||||
/// All of the following safety requirements are trivially satisfied for this usecase.
|
||||
///
|
||||
/// [`offset`]: #method.offset
|
||||
///
|
||||
/// # Safety
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue