pub struct TextRange {
pub start: u32,
pub end: u32,
}Expand description
Represents a range in the source text identified by byte offsets.
Fields§
§start: u32§end: u32Implementations§
Source§impl TextRange
impl TextRange
pub fn new(start: u32, end: u32) -> Self
Sourcepub fn overlaps(&self, other: &TextRange) -> bool
pub fn overlaps(&self, other: &TextRange) -> bool
Checks if this range overlaps with another.
Two ranges conflict only when they share byte positions; i.e. when applying both would write the same byte twice or write into bytes the other is deleting. Adjacency at a boundary is fine:
- Adjacent non-empty ranges (e.g.
0..5and5..10) do not overlap; they replace different bytes. - Two empty ranges at the same offset stack in insertion order; they each write their own bytes without touching the other’s.
- An empty range at the exact boundary of a non-empty one (e.g. an
insert at
5with a replace of5..10, or an insert at10with a replace of5..10) does not overlap; the stitcher resolves the order deterministically (insert-at-start goes before replacement; insert-at-end goes after).
Only interior containment of an empty range inside a non-empty one is treated as overlap, as is any interior overlap between two non-empty ranges.
Trait Implementations§
impl Copy for TextRange
impl Eq for TextRange
impl StructuralPartialEq for TextRange
Auto Trait Implementations§
impl Freeze for TextRange
impl RefUnwindSafe for TextRange
impl Send for TextRange
impl Sync for TextRange
impl Unpin for TextRange
impl UnsafeUnpin for TextRange
impl UnwindSafe for TextRange
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