pub struct TextRange { /* private fields */ }
Expand description
A range in the text, represented as a pair of TextUnit
s.
§Panics
Slicing a &str
with TextRange
panics if the result is
not a valid utf8 string.
Implementations§
Source§impl TextRange
impl TextRange
Sourcepub fn from_to(from: TextUnit, to: TextUnit) -> TextRange
pub fn from_to(from: TextUnit, to: TextUnit) -> TextRange
The left-inclusive range ([from..to)
) between to points in the text
Sourcepub fn offset_len(offset: TextUnit, len: TextUnit) -> TextRange
pub fn offset_len(offset: TextUnit, len: TextUnit) -> TextRange
The left-inclusive range ([offset..offset + len)
) between to points in the text
pub fn is_subrange(&self, other: &TextRange) -> bool
pub fn intersection(&self, other: &TextRange) -> Option<TextRange>
Sourcepub fn extend_to(&self, other: &TextRange) -> TextRange
pub fn extend_to(&self, other: &TextRange) -> TextRange
The smallest range that contains both ranges
pub fn contains(&self, offset: TextUnit) -> bool
pub fn contains_inclusive(&self, offset: TextUnit) -> bool
pub fn checked_sub(self, other: TextUnit) -> Option<TextRange>
Trait Implementations§
Source§impl<'a> AddAssign<&'a TextUnit> for TextRange
impl<'a> AddAssign<&'a TextUnit> for TextRange
Source§fn add_assign(&mut self, rhs: &'a TextUnit)
fn add_assign(&mut self, rhs: &'a TextUnit)
Performs the
+=
operation. Read moreSource§impl AddAssign<TextUnit> for TextRange
impl AddAssign<TextUnit> for TextRange
Source§fn add_assign(&mut self, rhs: TextUnit)
fn add_assign(&mut self, rhs: TextUnit)
Performs the
+=
operation. Read moreSource§impl RangeBounds<TextUnit> for TextRange
impl RangeBounds<TextUnit> for TextRange
Source§impl<'a> SubAssign<&'a TextUnit> for TextRange
impl<'a> SubAssign<&'a TextUnit> for TextRange
Source§fn sub_assign(&mut self, rhs: &'a TextUnit)
fn sub_assign(&mut self, rhs: &'a TextUnit)
Performs the
-=
operation. Read moreSource§impl SubAssign<TextUnit> for TextRange
impl SubAssign<TextUnit> for TextRange
Source§fn sub_assign(&mut self, rhs: TextUnit)
fn sub_assign(&mut self, rhs: TextUnit)
Performs the
-=
operation. Read moreimpl 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<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