diff options
| author | Chayim Refael Friedman <chayimfr@gmail.com> | 2023-01-23 14:42:32 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-23 14:42:32 +0200 |
| commit | 236f8231a64241d3fb3b9d81a8cd3175367e691d (patch) | |
| tree | dfc381b6f3a71c384ab991ddf8953049bab6e0ca | |
| parent | 6b3cd03fdb285781c60f5962194719fdfd46d910 (diff) | |
| download | rust-236f8231a64241d3fb3b9d81a8cd3175367e691d.tar.gz rust-236f8231a64241d3fb3b9d81a8cd3175367e691d.zip | |
`sub_ptr()` is equivalent to `usize::try_from().unwrap_unchecked()`, not `usize::from().unwrap_unchecked()`.
`usize::from()` gives a `usize`, not `Result<usize>`, and `usize: From<isize>` is not implemented.
| -rw-r--r-- | library/core/src/ptr/const_ptr.rs | 2 | ||||
| -rw-r--r-- | library/core/src/ptr/mut_ptr.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index 7b1cb5488bc..16eb726f6f6 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -731,7 +731,7 @@ impl<T: ?Sized> *const T { /// This computes the same value that [`offset_from`](#method.offset_from) /// would compute, but with the added precondition that the offset is /// guaranteed to be non-negative. This method is equivalent to - /// `usize::from(self.offset_from(origin)).unwrap_unchecked()`, + /// `usize::try_from(self.offset_from(origin)).unwrap_unchecked()`, /// but it provides slightly more information to the optimizer, which can /// sometimes allow it to optimize slightly better with some backends. /// diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index ed1e3bd4812..0a2f63e3ec6 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -904,7 +904,7 @@ impl<T: ?Sized> *mut T { /// This computes the same value that [`offset_from`](#method.offset_from) /// would compute, but with the added precondition that the offset is /// guaranteed to be non-negative. This method is equivalent to - /// `usize::from(self.offset_from(origin)).unwrap_unchecked()`, + /// `usize::try_from(self.offset_from(origin)).unwrap_unchecked()`, /// but it provides slightly more information to the optimizer, which can /// sometimes allow it to optimize slightly better with some backends. /// |
