Struct passerine::common::span::Span[][src]

pub struct Span {
    pub source: Option<Rc<Source>>,
    pub offset: usize,
    pub length: usize,
}
Expand description

A Span refers to a section of a source, much like a &str, but with a reference to a Source rather than a String. A Span is meant to be paired with other datastructures, to be used during error reporting.

Fields

source: Option<Rc<Source>>offset: usizelength: usize

Implementations

Create a new Span from an offset with a length. All Spans have access to the Source from whence they came, So they can’t be misinterpreted or miscombined.

A Span that points at a specific point in the source.

Create a new empty Span. An empty Span has only a source, if combined with another Span, the resulting Span will just be the other.

Checks if a Span is empty.

Return the index of the end of the Span.

Compares two Spans. Returns true if this span starts the latest or is the longest in the case of a tie but false there is a total tie or otherwise.

Creates a new Span which spans the space of the previous two.

hello this is cool
^^^^^              | Span a
           ^^      | Span b
^^^^^^^^^^^^^      | combined

Combines a set of Spans (think fold-left over Span::combine).

Returns the contents of a Span. This indexes into the source file, so if the Span is along an invalid byte boundary or is empty, the program will panic.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Given a Span, fmt will print out where the Span occurs in its source. Single-line Spans:

12 | x = blatant { error }
   |     ^^^^^^^^^^^^^^^^^

Multi-line Spans:

12 > x -> {
13 >    y = x + 1
14 >    another { error }
15 > }

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.