pub trait TextRangeExt {
// Required methods
fn as_byte_range(&self) -> Range<usize>;
fn as_u32_range(&self) -> Range<u32>;
fn intersects(&self, other: TextRange) -> bool;
}Expand description
Required Methods§
Sourcefn as_byte_range(&self) -> Range<usize>
fn as_byte_range(&self) -> Range<usize>
Convert to a half-open byte range suitable for slicing &str or
passing to codespan_reporting. Equivalent to
usize::from(self.start())..usize::from(self.end()).
Sourcefn as_u32_range(&self) -> Range<u32>
fn as_u32_range(&self) -> Range<u32>
Convert to a half-open u32 range. Useful for FFI / wire formats
that prefer u32 offsets over usize.
Sourcefn intersects(&self, other: TextRange) -> bool
fn intersects(&self, other: TextRange) -> bool
Returns true if the two ranges share at least one byte position
under the half-open convention. Zero-width ranges are handled
correctly — a caret at 10..10 intersects 10..15 but not
5..9.