Trait aho_corasick::packed::ext::Pointer
source · 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.
Object Safety§
This trait is not object safe.