Struct partiql_source_map::location::Located
source · pub struct Located<T, Loc: Display> {
pub inner: T,
pub location: Location<Loc>,
}
Expand description
A wrapper type that holds an inner
value and a location
for it
Fields§
§inner: T
The item that has a location attached
location: Location<Loc>
The location of the error
Implementations§
source§impl<T, Loc: Display> Located<T, Loc>
impl<T, Loc: Display> Located<T, Loc>
sourcepub fn map_loc<F, Loc2>(self, tx: F) -> Located<T, Loc2>where
Loc2: Display,
F: FnMut(Loc) -> Loc2,
pub fn map_loc<F, Loc2>(self, tx: F) -> Located<T, Loc2>where Loc2: Display, F: FnMut(Loc) -> Loc2,
Maps an Located<T, Loc>
to Located<T, Loc2>
by applying a function to the contained
location and moving the contained inner
Example
assert_eq!("blah".to_string()
.to_located(BytePosition::from(5)..BytePosition::from(10))
.map_loc(|BytePosition(o)| BytePosition(o+5)),
Located{
inner: "blah".to_string(),
location: (BytePosition(ByteOffset(10))..BytePosition(ByteOffset(15))).into()
});
Trait Implementations§
source§impl<T: PartialEq, Loc: PartialEq + Display> PartialEq<Located<T, Loc>> for Located<T, Loc>
impl<T: PartialEq, Loc: PartialEq + Display> PartialEq<Located<T, Loc>> for Located<T, Loc>
impl<T: Eq, Loc: Eq + Display> Eq for Located<T, Loc>
impl<T, Loc: Display> StructuralEq for Located<T, Loc>
impl<T, Loc: Display> StructuralPartialEq for Located<T, Loc>
Auto Trait Implementations§
impl<T, Loc> RefUnwindSafe for Located<T, Loc>where Loc: RefUnwindSafe, T: RefUnwindSafe,
impl<T, Loc> Send for Located<T, Loc>where Loc: Send, T: Send,
impl<T, Loc> Sync for Located<T, Loc>where Loc: Sync, T: Sync,
impl<T, Loc> Unpin for Located<T, Loc>where Loc: Unpin, T: Unpin,
impl<T, Loc> UnwindSafe for Located<T, Loc>where Loc: UnwindSafe, 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<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.