Span

Type Alias Span 

Source
pub type Span<'f, L> = SpanT<&'f str, L>;
Expand description

A SpanT with a borrowed string file name.

Used widely by the lexer and parser because it appears in every syntactic construct and is cheap to copy.

If the SpanT must own its filename, use SpanRc instead.

Aliased Type§

pub struct Span<'f, L> {
    pub file_name: &'f str,
    pub start: L,
    pub end: L,
}

Fields§

§file_name: &'f str

The name of the source code.

Often a file name, but can be an arbitrary string like <input> or even any other type.

§start: L

The (inclusive) starting location.

§end: L

The (exclusive) ending location.

Implementations§

Source§

impl<'f, L: Clone> Span<'f, L>

Source

pub fn with_rc(&self) -> SpanRc<L>

Converts a Span into a SpanRc by cloning the borrowed file name.

Source

pub fn with_owned(&self) -> SpanT<String, L>

Converts a Span into a SpanT which owns its data by cloning the borrowed file name.