pub struct TextUnit(_);
Expand description
An offset into text.
Offset is represented as u32
storing number of utf8-bytes,
but most of the clients should treat it like opaque measure.
Implementations
sourceimpl TextUnit
impl TextUnit
sourcepub fn of_str(s: &str) -> TextUnit
pub fn of_str(s: &str) -> TextUnit
TextUnit
equal to the length of this string.
Panics
Panics if the length of the string is greater than u32::max_value()
pub fn checked_sub(self, other: TextUnit) -> Option<TextUnit>
pub fn from_usize(size: usize) -> TextUnit
pub fn to_usize(self) -> usize
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<'a> AddAssign<&'a TextUnit> for TextUnit
impl<'a> AddAssign<&'a TextUnit> for TextUnit
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 AddAssign<TextUnit> for TextUnit
impl AddAssign<TextUnit> for TextUnit
sourcefn add_assign(&mut self, rhs: TextUnit)
fn add_assign(&mut self, rhs: TextUnit)
Performs the
+=
operation. Read moresourceimpl Ord for TextUnit
impl Ord for TextUnit
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<TextUnit> for TextUnit
impl PartialOrd<TextUnit> for TextUnit
sourcefn partial_cmp(&self, other: &TextUnit) -> Option<Ordering>
fn partial_cmp(&self, other: &TextUnit) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. 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<'a> SubAssign<&'a TextUnit> for TextUnit
impl<'a> SubAssign<&'a TextUnit> for TextUnit
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 moresourceimpl SubAssign<TextUnit> for TextUnit
impl SubAssign<TextUnit> for TextUnit
sourcefn sub_assign(&mut self, rhs: TextUnit)
fn sub_assign(&mut self, rhs: TextUnit)
Performs the
-=
operation. Read moreimpl Copy for TextUnit
impl Eq for TextUnit
impl StructuralEq for TextUnit
impl StructuralPartialEq for TextUnit
Auto Trait Implementations
impl RefUnwindSafe for TextUnit
impl Send for TextUnit
impl Sync for TextUnit
impl Unpin for TextUnit
impl UnwindSafe for TextUnit
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