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
sourceimpl 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
sourceimpl<'a> AddAssign<&'a TextUnit> for TextRange
impl<'a> AddAssign<&'a TextUnit> for TextRange
sourcefn add_assign(&mut self, rhs: &'a TextUnit)
fn add_assign(&mut self, rhs: &'a TextUnit)
Performs the
+=
operation. Read moresourceimpl AddAssign<TextUnit> for TextRange
impl AddAssign<TextUnit> for TextRange
sourcefn add_assign(&mut self, rhs: TextUnit)
fn add_assign(&mut self, rhs: TextUnit)
Performs the
+=
operation. Read moresourceimpl RangeBounds<TextUnit> for TextRange
impl RangeBounds<TextUnit> for TextRange
sourcefn start_bound(&self) -> Bound<&TextUnit>
fn start_bound(&self) -> Bound<&TextUnit>
Start index bound. Read more
1.35.0 · sourcefn contains<U>(&self, item: &U) -> boolwhere
T: PartialOrd<U>,
U: PartialOrd<T> + ?Sized,
fn contains<U>(&self, item: &U) -> boolwhere
T: PartialOrd<U>,
U: PartialOrd<T> + ?Sized,
sourceimpl<'a> SubAssign<&'a TextUnit> for TextRange
impl<'a> SubAssign<&'a TextUnit> for TextRange
sourcefn sub_assign(&mut self, rhs: &'a TextUnit)
fn sub_assign(&mut self, rhs: &'a TextUnit)
Performs the
-=
operation. Read moresourceimpl SubAssign<TextUnit> for TextRange
impl SubAssign<TextUnit> for TextRange
sourcefn 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 StructuralEq for TextRange
impl StructuralPartialEq for TextRange
Auto Trait Implementations
impl RefUnwindSafe for TextRange
impl Send for TextRange
impl Sync for TextRange
impl Unpin for TextRange
impl UnwindSafe for TextRange
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more