Struct passerine::common::span::Span [−][src]
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: usize
length: usize
Implementations
impl Span
[src]
pub fn new(source: &Rc<Source>, offset: usize, length: usize) -> Span
[src]
Create a new Span
from an offset with a length.
All Span
s have access to the Source
from whence they came,
So they can’t be misinterpreted or miscombined.
pub fn point(source: &Rc<Source>, offset: usize) -> Span
[src]
A Span
that points at a specific point in the source.
pub fn empty() -> Span
[src]
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.
pub fn is_empty(&self) -> bool
[src]
Checks if a Span
is empty.
pub fn end(&self) -> usize
[src]
Return the index of the end of the Span
.
pub fn later_than(&self, other: &Span) -> bool
[src]
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.
pub fn combine(a: &Span, b: &Span) -> Span
[src]
Creates a new Span
which spans the space of the previous two.
hello this is cool
^^^^^ | Span a
^^ | Span b
^^^^^^^^^^^^^ | combined
pub fn join(spans: Vec<Span>) -> Span
[src]
Combines a set of Span
s (think fold-left over Span::combine
).
pub fn contents(&self) -> String
[src]
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
impl Clone for Span
[src]
impl Debug for Span
[src]
impl Display for Span
[src]
fn fmt(&self, f: &mut Formatter<'_>) -> Result
[src]
Given a Span
, fmt
will print out where the Span
occurs in its source.
Single-line Span
s:
12 | x = blatant { error }
| ^^^^^^^^^^^^^^^^^
Multi-line Span
s:
12 > x -> {
13 > y = x + 1
14 > another { error }
15 > }
impl Eq for Span
[src]
impl PartialEq<Span> for Span
[src]
impl StructuralEq for Span
[src]
impl StructuralPartialEq for Span
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,