Struct Span
pub struct Span { /* private fields */ }Expand description
Represents an interval of memory [base, acme)
Use get_base_acme to retrieve base and acme directly.
§Empty Spans
Note that where base >= acme, the Span is considered empty, in which case
the specific values of base and acme are considered meaningless.
- Empty spans contain nothing and overlap with nothing.
- Empty spans are contained by any sized span.
Implementations§
§impl Span
impl Span
pub const fn from_base_size(base: *mut u8, size: usize) -> Span
pub const fn from_base_size(base: *mut u8, size: usize) -> Span
Creates a Span given a base and a size.
If base + size overflows, the result is empty.
pub const fn from_array<T, const N: usize>(array: *mut [T; N]) -> Span
pub const fn from_const_array<T, const N: usize>(array: *const [T; N]) -> Span
pub fn to_ptr_range(self) -> Option<Range<*mut u8>>
pub fn to_ptr_range(self) -> Option<Range<*mut u8>>
Returns None if self is empty.
pub fn contains(self, ptr: *mut u8) -> bool
pub fn contains(self, ptr: *mut u8) -> bool
Returns whether self contains addr.
Empty spans contain nothing.
pub fn contains_span(self, other: Span) -> bool
pub fn contains_span(self, other: Span) -> bool
Returns whether self contains other.
Empty spans are contained by any span, even empty ones.
pub fn overlaps(self, other: Span) -> bool
pub fn overlaps(self, other: Span) -> bool
Returns whether some of self overlaps with other.
Empty spans don’t overlap with anything.
pub fn word_align_inward(self) -> Span
pub fn word_align_inward(self) -> Span
Aligns base upward and acme downward by align_of::<usize>().
pub fn word_align_outward(self) -> Span
pub fn word_align_outward(self) -> Span
Aligns base downward and acme upward by align_of::<usize>().
pub fn except(self, exclude: Span) -> (Span, Span)
pub fn except(self, exclude: Span) -> (Span, Span)
Returns the Spans of self below and above the exclude span, respectively.
Alternatively worded, the set difference self\exclude.
If exclude is empty, self and an empty Span are returned.
pub fn fit_within(self, other: Span) -> Span
pub fn fit_within(self, other: Span) -> Span
Returns a span that other contains by raising base or lowering acme.
If other is empty, returns other.
pub fn fit_over(self, other: Span) -> Span
pub fn fit_over(self, other: Span) -> Span
Returns a span that contains other by extending self.
If other is empty, returns self, as all spans contain any empty span.
Trait Implementations§
impl Copy for Span
impl Eq for Span
impl Send for Span
Auto Trait Implementations§
impl Freeze for Span
impl RefUnwindSafe for Span
impl !Sync for Span
impl Unpin for Span
impl UnsafeUnpin for Span
impl UnwindSafe for Span
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.