pub enum Span {
Empty,
Sized {
base: isize,
acme: isize,
},
}Variants§
Implementations§
source§impl Span
impl Span
pub const fn new(base: isize, acme: isize) -> Self
sourcepub const fn from_base_size(base: isize, size: usize) -> Self
pub const fn from_base_size(base: isize, size: usize) -> Self
If the base is greater than acme, returns a span with the given
base and a size of zero.
pub fn from_ptr_size(ptr: *mut u8, size: usize) -> Self
pub fn from_ptr_slice(slice: *mut [u8]) -> Self
pub fn from_ptr_range(range: Range<*mut u8>) -> Self
pub const fn to_ptr_range(self) -> Option<Range<*mut u8>>
pub const fn to_slice(self) -> Option<*mut [u8]>
pub const fn is_empty(self) -> bool
pub const fn size(self) -> usize
sourcepub const fn contains(self, addr: isize) -> bool
pub const fn contains(self, addr: isize) -> bool
Returns whether self contains other.
Signed comparisons are used.
sourcepub fn contains_ptr(self, ptr: *mut u8) -> bool
pub fn contains_ptr(self, ptr: *mut u8) -> bool
Returns whether self contains other.
Signed comparisons are used.
sourcepub const fn contains_span(self, span: Span) -> bool
pub const fn contains_span(self, span: Span) -> bool
Returns whether self contains other.
Empty spans are contained by any span, even empty ones.
sourcepub const fn overlaps(self, span: Span) -> bool
pub const fn overlaps(self, span: Span) -> bool
Returns whether some of self overlaps some of other.
Empty spans don’t overlap with anything.
sourcepub const fn word_align_inward(self) -> Self
pub const fn word_align_inward(self) -> Self
Aligns base upward and acme() downward by align_of::<usize>().
sourcepub const fn word_align_outward(self) -> Self
pub const fn word_align_outward(self) -> Self
Aligns base downward and acme upward by align_of::<usize>().
sourcepub const fn fit_within(self, span: Span) -> Self
pub const fn fit_within(self, span: Span) -> Self
Returns a span that other contains by raising base or lowering acme.
If other is empty, returns other.
sourcepub const fn fit_over(self, span: Self) -> Self
pub const fn fit_over(self, span: Self) -> Self
Returns a span that contains other by extending self.
If other is empty, returns self, as all spans contain any empty span.
Trait Implementations§
source§impl PartialEq<Span> for Span
impl PartialEq<Span> for Span
impl Copy for Span
impl Eq for Span
impl StructuralEq for Span
impl StructuralPartialEq for Span
Auto Trait Implementations§
impl RefUnwindSafe for Span
impl Send for Span
impl Sync for Span
impl Unpin 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
Mutably borrows from an owned value. Read more