Function orx_pinned_vec::utils::slice::contains_ptr

source ·
pub fn contains_ptr<T>(slice: &[T], element_ptr: *const T) -> bool
Expand description

Returns whether or not element with the given pointer belongs to the given slice. This method has O(1) time complexity.

§Safety

The underlying memory of the slice &[T] stays pinned as long as the reference is in scope; i.e., is not carried to different memory locations.

Therefore, it is possible and safe to compare an element’s reference to find its position in the vector.

Out of bounds checks are in place.