pub(crate) trait Pointer {
    // Required methods
    unsafe fn distance(self, origin: Self) -> usize;
    fn as_usize(self) -> usize;
}Expand description
A trait for adding some helper routines to pointers.
Required Methods§
Sourceunsafe fn distance(self, origin: Self) -> usize
 
unsafe fn distance(self, origin: Self) -> usize
Returns the distance, in units of T, between self and origin.
§Safety
Same as ptr::offset_from in addition to self >= origin.
Sourcefn as_usize(self) -> usize
 
fn as_usize(self) -> usize
Casts this pointer to usize.
Callers should not convert the usize back to a pointer if at all
possible. (And if you believe it’s necessary, open an issue to discuss
why. Otherwise, it has the potential to violate pointer provenance.)
The purpose of this function is just to be able to do arithmetic, i.e.,
computing offsets or alignments.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.