Span

Struct Span 

Source
pub struct Span { /* private fields */ }
Expand description

a span of start and end Locations in a Buffer

Implementations§

Source§

impl Span

Source

pub fn new(start: Loc, end: Loc) -> Self

construct a span from two Locations

§Panics

if the span is backwards, or if the locations are in different Buffers

Source

pub fn start(&self) -> Loc

get the start of the span

Source

pub fn end(&self) -> Loc

get the start of the span

Source

pub fn is_empty(&self) -> bool

returns whether the span’s length is 0

Source

pub fn len(&self) -> u32

the length in bytes this span covers

Source

pub fn contains(&self, loc: &Loc) -> bool

returns whether this span contains the given Location

Source

pub fn contains_span(&self, subspan: &Self) -> bool

returns whether this span contains the given span

Source

pub fn subspan<B: RangeBounds<u32>>(self, range: B) -> Self

take a sub-span, using a range of this span’s source

§Panics

if the sub-span is backwards

Source

pub fn union(&self, with: &Self) -> Self

construct a span that covers both this one and the given one (and anything between them)

§Panics

if the spans are in different Buffers

Source

pub fn intersection(&self, with: &Self) -> Option<Self>

construct a span that covers the shared area of both this span and the given one

§Panics

if the spans are in different Buffers

Source

pub fn with_len(&self, len: u32) -> Self

construct a Span starting where self starts, with the given length

Source

pub fn same_buf_as(&self, loc: Loc) -> bool

returns whether both locations are in the same Buffer

Trait Implementations§

Source§

impl Clone for Span

Source§

fn clone(&self) -> Span

Returns a duplicate 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, fmt: &mut Formatter<'_>) -> Result

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

impl Default for Span

Source§

fn default() -> Span

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

impl From<Loc> for Span

Source§

fn from(loc: Loc) -> Self

Converts to this type from the input type.
Source§

impl From<Range<Loc>> for Span

Source§

fn from(span: Range<Loc>) -> Self

Converts to this type from the input type.
Source§

impl<Src: BufferSource> From<SrcSpan<Src>> for Span

Source§

fn from(src_span: SrcSpan<Src>) -> Self

Converts to this type from the input type.
Source§

impl Hash for Span

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Src: BufferSource> Index<Span> for Buffer<Src>

Source§

type Output = str

The returned type after indexing.
Source§

fn index(&self, span: Span) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl PartialEq for Span

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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 StructuralPartialEq for Span

Auto Trait Implementations§

§

impl Freeze for Span

§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> SpannerExt for T

Source§

fn locd(self, loc: Loc) -> Locd<Self>

helper extension method to quickly wrap values in Locd
Source§

fn spanned(self, span: Span) -> Spanned<Self>

helper extension method to quickly wrap values in Spanned
Source§

fn src_spanned<Src: BufferSource>( self, src_span: SrcSpan<Src>, ) -> SrcSpanned<Self, Src>

helper extension method to quickly wrap values in SrcSpanned
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.