pub struct TextRange { /* private fields */ }
Expand description
Defines a range in a text.
A range is defined by two InsertPosition
s, start
and end
. All the
text between the two positions is included in the range.
Implementations§
Source§impl TextRange
impl TextRange
Sourcepub fn new(start: InsertPosition, end: InsertPosition) -> Self
pub fn new(start: InsertPosition, end: InsertPosition) -> Self
Create a new text range containing everything between start
and end
.
They may point to the same location (in which case the range is empty),
but end
may not be before start
.
Sourcepub fn new_empty(pos: InsertPosition) -> Self
pub fn new_empty(pos: InsertPosition) -> Self
Create a new empty range at pos
.
Sourcepub fn inc(&mut self, c: char)
pub fn inc(&mut self, c: char)
Append one character to the range.
If the character c
is a newline, it behaves like [inc_line()
],
otherwhise it behaves like [inc_col()
].
Sourcepub fn merge(&mut self, other: TextRange)
pub fn merge(&mut self, other: TextRange)
Merge other
into self
.
self.end()
must line up (ie. be equal to) other.start()
. This means
there may be no characters between the two ranges.
Sourcepub fn begin_next_range(&self) -> Self
pub fn begin_next_range(&self) -> Self
Create a new empty range starting at the end of self
Sourcepub fn start(&self) -> &InsertPosition
pub fn start(&self) -> &InsertPosition
Get the start insert position
Sourcepub fn end(&self) -> &InsertPosition
pub fn end(&self) -> &InsertPosition
Get the end insert position
Trait Implementations§
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 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