pub struct TextRange { /* private fields */ }Expand description
A range in the text, represented as a pair of TextUnits.
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
1.35.0 · source§fn 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,
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 more