Trait ariadne::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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Span for Range<usize>

§

type SourceId = ()

source§

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

source§

fn start(&self) -> usize

source§

fn end(&self) -> usize

source§

impl<Id: Debug + Hash + PartialEq + Eq + ToOwned> Span for (Id, Range<usize>)

§

type SourceId = Id

source§

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

source§

fn start(&self) -> usize

source§

fn end(&self) -> usize

Implementors§