pub struct Spanned<T> {
pub value: T,
pub span: Span,
}
Expand description
A wrapper that associates a span with a value.
Fields§
§value: T
§span: Span
Implementations§
Source§impl<T> Spanned<T>
impl<T> Spanned<T>
Sourcepub fn new(value: T, span: Span) -> Spanned<T>
pub fn new(value: T, span: Span) -> Spanned<T>
Wrap a given value together with the span it covers.
Sourcepub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Spanned<U>
pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Spanned<U>
Map the spanned value, preserving the span.
pub fn map_into<U>(self) -> Spanned<U>where
T: Into<U>,
pub fn as_ref(&self) -> Spanned<&T>
Trait Implementations§
Source§impl<T> HasSpan for Spanned<T>
impl<T> HasSpan for Spanned<T>
Source§fn human_span(&self) -> Span
fn human_span(&self) -> Span
Obtain a span which can be used to refer to this node in error messages
presented to humans. This will generally be the name for things like
entities, processes, and variables. Defaults to return whatever
span()
returns.Source§impl<T: Ord> Ord for Spanned<T>
impl<T: Ord> Ord for Spanned<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialOrd> PartialOrd for Spanned<T>
impl<T: PartialOrd> PartialOrd for Spanned<T>
impl<T> Copy for Spanned<T>where
T: Copy,
impl<T: Eq> Eq for Spanned<T>
impl<T> StructuralPartialEq for Spanned<T>
Auto Trait Implementations§
impl<T> Freeze for Spanned<T>where
T: Freeze,
impl<T> RefUnwindSafe for Spanned<T>where
T: RefUnwindSafe,
impl<T> Send for Spanned<T>where
T: Send,
impl<T> Sync for Spanned<T>where
T: Sync,
impl<T> Unpin for Spanned<T>where
T: Unpin,
impl<T> UnwindSafe for Spanned<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more