Type Alias arithmetic_parser::Location

source ·
pub type Location<T = ()> = LocatedSpan<usize, T>;
Expand description

Value with an associated code location. Unlike Spanned, Location does not retain a reference to the original code span, just its start position and length.

Aliased Type§

struct Location<T = ()> {
    pub extra: T,
    /* private fields */
}

Fields§

§extra: T

Extra information that can be embedded by the user.

Implementations§

source§

impl Location

source

pub fn from_str<'a, R>(code: &'a str, range: R) -> Self
where InputSpan<'a>: Slice<R>,

Creates a location from a range in the provided code. This is mostly useful for testing.

source§

impl<T> Location<T>

source

pub fn to_string(&self, default_name: &str) -> String

Returns a string representation of this location in the form {default_name} at {line}:{column}.

source

pub fn span<'a>(&self, code: &'a str) -> &'a str

Returns this location in the provided code. It is caller’s responsibility to ensure that this is called with the original code that produced this location.

Trait Implementations§

source§

impl<T> From<LocatedSpan<&str, T>> for Location<T>

source§

fn from(value: Spanned<'_, T>) -> Self

Converts to this type from the input type.