Type Alias MaybeSpanned

Source
pub type MaybeSpanned<'a, T = ()> = LocatedSpan<CodeFragment<'a>, T>;
Expand description

Value with an optional associated code span.

Aliased Type§

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

Fields§

§extra: T

Extra information that can be embedded by the user.

Implementations§

Source§

impl<'a> MaybeSpanned<'a>

Source

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

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

Source§

impl<T> MaybeSpanned<'_, T>

Source

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

Returns either the original code fragment (if it’s retained), or a string in the form {default_name} at {line}:{column}.

Trait Implementations§

Source§

impl<'a, T> From<LocatedSpan<&'a str, T>> for MaybeSpanned<'a, T>

Source§

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

Converts to this type from the input type.
Source§

impl<T: Clone + 'static> StripCode for MaybeSpanned<'_, T>

Source§

type Stripped = LocatedSpan<CodeFragment<'static>, T>

Resulting type after code stripping.
Source§

fn strip_code(self) -> Self::Stripped

Strips references to code fragments in this type.