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: TThe 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()
});