@@ -987,8 +987,8 @@ extern "rust-intrinsic" {
987
987
/// std::mem::transmute::<&i32, usize>(ptr)
988
988
/// };
989
989
///
990
- /// // Use an `as` cast instead
991
- /// let ptr_num_cast = ptr as *const i32 as usize ;
990
+ /// // Use `.addr()` instead
991
+ /// let ptr_num_cast = ( ptr as *const i32).addr() ;
992
992
/// ```
993
993
///
994
994
/// Turning a `*mut T` into an `&mut T`:
@@ -1972,15 +1972,15 @@ extern "rust-intrinsic" {
1972
1972
/// Checks whether `ptr` is properly aligned with respect to
1973
1973
/// `align_of::<T>()`.
1974
1974
pub ( crate ) fn is_aligned_and_not_null < T > ( ptr : * const T ) -> bool {
1975
- !ptr. is_null ( ) && ptr as usize % mem:: align_of :: < T > ( ) == 0
1975
+ !ptr. is_null ( ) && ptr. addr ( ) % mem:: align_of :: < T > ( ) == 0
1976
1976
}
1977
1977
1978
1978
/// Checks whether the regions of memory starting at `src` and `dst` of size
1979
1979
/// `count * size_of::<T>()` do *not* overlap.
1980
1980
#[ cfg( debug_assertions) ]
1981
1981
pub ( crate ) fn is_nonoverlapping < T > ( src : * const T , dst : * const T , count : usize ) -> bool {
1982
- let src_usize = src as usize ;
1983
- let dst_usize = dst as usize ;
1982
+ let src_usize = src. addr ( ) ;
1983
+ let dst_usize = dst. addr ( ) ;
1984
1984
let size = mem:: size_of :: < T > ( ) . checked_mul ( count) . unwrap ( ) ;
1985
1985
let diff = if src_usize > dst_usize { src_usize - dst_usize } else { dst_usize - src_usize } ;
1986
1986
// If the absolute distance between the ptrs is at least as big as the size of the buffer,
0 commit comments