pub struct RangeMapper { /* private fields */ }Expand description
Remaps ranges.
Useful in combination with
SyntaxNode::synthesize_mapped to
have accurate error spans for source text that is non-consecutive in its
source file (for instance, Typst code in a doc comment with start-of-line
slashes).
Implementations§
Source§impl RangeMapper
impl RangeMapper
Sourcepub fn new(
segments: impl IntoIterator<Item = Range<usize>>,
) -> Result<Self, EcoString>
pub fn new( segments: impl IntoIterator<Item = Range<usize>>, ) -> Result<Self, EcoString>
Creates a new range mapper.
The iterator should returns ranges in the original text that will be consecutively concatenated to produce the derived text.
Segments should be in order. (The start of a later range must not precede the end of an earlier range.)
Note that this representation implies that ranges can only ever increase in their start position and length when mapped.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RangeMapper
impl RefUnwindSafe for RangeMapper
impl Send for RangeMapper
impl Sync for RangeMapper
impl Unpin for RangeMapper
impl UnsafeUnpin for RangeMapper
impl UnwindSafe for RangeMapper
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> 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