pub struct Loc<T> {
pub value: T,
pub span: Option<Span>,
}Expand description
Wrap any type with location information.
Loc is used to wrap a type to give it location information. It is a simple struct adjoining
any given type to an Option<Span> and implementing Located and Locatable. This is meant to
be done to types that are not under control and cannot be made to implement the traits directly
because of the orphan instance rules, or because giving them a Span all the time does not make
sense. Otherwise, deriving Located and Locatable directly using the associated derive
macros is preferred.
It is often controverial to decide whether a Located type should compare equal accounting for its span or not. For this reason, Loc intentionally does not implement PartialEq nor Eq.
Fields§
§value: T§span: Option<Span>Implementations§
Trait Implementations§
impl<T: Eq> Eq for Loc<T>
Source§impl<T: Error> Error for Loc<T>
impl<T: Error> Error for Loc<T>
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
impl<T: PartialEq> StructuralPartialEq for Loc<T>
Auto Trait Implementations§
impl<T> Freeze for Loc<T>where
T: Freeze,
impl<T> RefUnwindSafe for Loc<T>where
T: RefUnwindSafe,
impl<T> Send for Loc<T>where
T: Send,
impl<T> Sync for Loc<T>where
T: Sync,
impl<T> Unpin for Loc<T>where
T: Unpin,
impl<T> UnsafeUnpin for Loc<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Loc<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more