Enum talloc::Span

source ·
pub enum Span {
    Empty,
    Sized {
        base: isize,
        acme: isize,
    },
}

Variants§

§

Empty

§

Sized

Fields

§base: isize
§acme: isize

Implementations§

source§

impl Span

source

pub const fn new(base: isize, acme: isize) -> Self

source

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.

source

pub fn from_ptr_size(ptr: *mut u8, size: usize) -> Self

source

pub fn from_ptr_slice(slice: *mut [u8]) -> Self

source

pub fn from_ptr_range(range: Range<*mut u8>) -> Self

source

pub const fn to_ptr_range(self) -> Option<Range<*mut u8>>

source

pub const fn to_slice(self) -> Option<*mut [u8]>

source

pub const fn is_empty(self) -> bool

source

pub const fn size(self) -> usize

source

pub const fn contains(self, addr: isize) -> bool

Returns whether self contains other.

Signed comparisons are used.

source

pub fn contains_ptr(self, ptr: *mut u8) -> bool

Returns whether self contains other.

Signed comparisons are used.

source

pub const fn contains_span(self, span: Span) -> bool

Returns whether self contains other.

Empty spans are contained by any span, even empty ones.

source

pub const fn overlaps(self, span: Span) -> bool

Returns whether some of self overlaps some of other.

Empty spans don’t overlap with anything.

source

pub const fn word_align_inward(self) -> Self

Aligns base upward and acme() downward by align_of::<usize>().

source

pub const fn word_align_outward(self) -> Self

Aligns base downward and acme upward by align_of::<usize>().

source

pub const fn above(self, min: isize) -> Self

Raises base if base is smaller than min.

source

pub const fn below(self, max: isize) -> Self

Lowers acme if acme is greater than max.

source

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.

source

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.

source

pub const fn extend(self, low: usize, high: usize) -> Self

Lower base by low and raise acme by high.

source

pub const fn truncate(self, low: usize, high: usize) -> Span

Raise base by low and lower size by low + high (zero, if this underflows).

Trait Implementations§

source§

impl Clone for Span

source§

fn clone(&self) -> Span

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Span

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Span

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for Span

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<&mut [u8]> for Span

source§

fn from(value: &mut [u8]) -> Self

Converts to this type from the input type.
source§

impl From<*mut [u8]> for Span

source§

fn from(value: *mut [u8]) -> Self

Converts to this type from the input type.
source§

impl From<Range<*mut u8>> for Span

source§

fn from(value: Range<*mut u8>) -> Self

Converts to this type from the input type.
source§

impl From<Range<isize>> for Span

source§

fn from(value: Range<isize>) -> Self

Converts to this type from the input type.
source§

impl PartialEq<Span> for Span

source§

fn eq(&self, other: &Span) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Span

source§

impl Eq for Span

source§

impl StructuralEq for Span

source§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.