Trait Span

Source
pub trait Span {
    type SourceId: PartialEq + ToOwned + ?Sized;

    // Required methods
    fn source(&self) -> &Self::SourceId;
    fn start(&self) -> usize;
    fn end(&self) -> usize;

    // Provided methods
    fn len(&self) -> usize { ... }
    fn contains(&self, offset: usize) -> bool { ... }
}
Expand description

A trait implemented by spans within a character-based source.

Required Associated Types§

Source

type SourceId: PartialEq + ToOwned + ?Sized

The identifier used to uniquely refer to a source. In most cases, this is the fully-qualified path of the file.

Required Methods§

Source

fn source(&self) -> &Self::SourceId

Get the identifier of the source that this span refers to.

Source

fn start(&self) -> usize

Get the start offset of this span.

Offsets are zero-indexed character offsets from the beginning of the source.

Source

fn end(&self) -> usize

Get the (exclusive) end offset of this span.

The end offset should always be greater than or equal to the start offset as given by Span::start.

Offsets are zero-indexed character offsets from the beginning of the source.

Provided Methods§

Source

fn len(&self) -> usize

Get the length of this span (difference between the start of the span and the end of the span).

Source

fn contains(&self, offset: usize) -> bool

Determine whether the span contains the given offset.

Implementors§