SpannedLike

Trait SpannedLike 

Source
pub trait SpannedLike<T>: Clone {
    type Span: SpanLike;

    // Required methods
    fn span(&self) -> &Self::Span;
    fn value_ref(&self) -> &T;
    fn value(self) -> T;
    fn new(start: usize, end: usize, value: T) -> Self;

    // Provided method
    fn map<U, F>(self, f: F) -> impl SpannedLike<U, Span = Self::Span>
       where U: Clone,
             F: FnOnce(T) -> U,
             Self: Sized { ... }
}
Expand description

A value paired with its source location span.

Wraps any value T with span information for error reporting and source mapping. Implementations must be Clone to support backtracking.

Required Associated Types§

Source

type Span: SpanLike

The span type used to track source locations.

Required Methods§

Source

fn span(&self) -> &Self::Span

Returns a reference to the span.

Source

fn value_ref(&self) -> &T

Returns a reference to the wrapped value.

Source

fn value(self) -> T

Consumes self and returns the wrapped value.

Source

fn new(start: usize, end: usize, value: T) -> Self

Creates a new spanned value from offsets and a value.

Provided Methods§

Source

fn map<U, F>(self, f: F) -> impl SpannedLike<U, Span = Self::Span>
where U: Clone, F: FnOnce(T) -> U, Self: Sized,

Maps the inner value while preserving the span.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§