pub struct TextRange {
pub start: TextPosition,
pub end: TextPosition,
}Expand description
Exclusive range for text ranges.
Fields§
§start: TextPositioncolumn, row
end: TextPositioncolumn, row
Implementations§
Source§impl TextRange
impl TextRange
Sourcepub fn new(
start: impl Into<TextPosition>,
end: impl Into<TextPosition>,
) -> TextRange
pub fn new( start: impl Into<TextPosition>, end: impl Into<TextPosition>, ) -> TextRange
New text range.
Panic Panics if start > end.
Sourcepub fn contains_pos(&self, pos: impl Into<TextPosition>) -> bool
pub fn contains_pos(&self, pos: impl Into<TextPosition>) -> bool
Range contains the given position.
Sourcepub fn before_pos(&self, pos: impl Into<TextPosition>) -> bool
pub fn before_pos(&self, pos: impl Into<TextPosition>) -> bool
Range fully before the given position.
Sourcepub fn after_pos(&self, pos: impl Into<TextPosition>) -> bool
pub fn after_pos(&self, pos: impl Into<TextPosition>) -> bool
Range fully after the given position.
Sourcepub fn intersects(&self, other: TextRange) -> bool
pub fn intersects(&self, other: TextRange) -> bool
Range overlaps with other range.
Sourcepub fn expand(&self, range: TextRange) -> TextRange
pub fn expand(&self, range: TextRange) -> TextRange
Return the modified value range, that accounts for a text insertion of range.
Sourcepub fn expand_pos(&self, pos: TextPosition) -> TextPosition
pub fn expand_pos(&self, pos: TextPosition) -> TextPosition
Return the modified position, that accounts for a text insertion of range.
Sourcepub fn shrink(&self, range: TextRange) -> TextRange
pub fn shrink(&self, range: TextRange) -> TextRange
Return the modified value range, that accounts for a text deletion of range.
Sourcepub fn shrink_pos(&self, pos: TextPosition) -> TextPosition
pub fn shrink_pos(&self, pos: TextPosition) -> TextPosition
Return the modified position, that accounts for a text deletion of the range.
Trait Implementations§
Source§impl Ord for TextRange
impl Ord for TextRange
Source§impl PartialOrd for TextRange
impl PartialOrd for TextRange
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 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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