[][src]Struct text_unit::TextRange

pub struct TextRange { /* fields omitted */ }

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.

Methods

impl TextRange[src]

pub fn from_to(from: TextUnit, to: TextUnit) -> TextRange[src]

The left-inclusive range ([from..to)) between to points in the text

pub fn offset_len(offset: TextUnit, len: TextUnit) -> TextRange[src]

The left-inclusive range ([offset..offset + len)) between to points in the text

pub fn start(&self) -> TextUnit[src]

The inclusive start of this range

pub fn end(&self) -> TextUnit[src]

The exclusive end of this range

pub fn len(&self) -> TextUnit[src]

The length of this range

pub fn is_empty(&self) -> bool[src]

Is this range empty of any content?

pub fn is_subrange(&self, other: &TextRange) -> bool[src]

pub fn intersection(&self, other: &TextRange) -> Option<TextRange>[src]

pub fn extend_to(&self, other: &TextRange) -> TextRange[src]

The smallest range that contains both ranges

pub fn contains(&self, offset: TextUnit) -> bool[src]

pub fn contains_inclusive(&self, offset: TextUnit) -> bool[src]

pub fn checked_sub(self, other: TextUnit) -> Option<TextRange>[src]

Trait Implementations

impl<'a> Add<&'a TextUnit> for TextRange[src]

type Output = TextRange

The resulting type after applying the + operator.

impl<'a, 'b> Add<&'a TextUnit> for &'b TextRange[src]

type Output = TextRange

The resulting type after applying the + operator.

impl Add<TextUnit> for TextRange[src]

type Output = TextRange

The resulting type after applying the + operator.

impl<'a> Add<TextUnit> for &'a TextRange[src]

type Output = TextRange

The resulting type after applying the + operator.

impl<'a> AddAssign<&'a TextUnit> for TextRange[src]

impl AddAssign<TextUnit> for TextRange[src]

impl Clone for TextRange[src]

impl Copy for TextRange[src]

impl Debug for TextRange[src]

impl Display for TextRange[src]

impl Eq for TextRange[src]

impl Hash for TextRange[src]

impl Index<TextRange> for str[src]

type Output = str

The returned type after indexing.

impl Index<TextRange> for String[src]

type Output = str

The returned type after indexing.

impl PartialEq<TextRange> for TextRange[src]

impl RangeBounds<TextUnit> for TextRange[src]

impl StructuralEq for TextRange[src]

impl StructuralPartialEq for TextRange[src]

impl<'a> Sub<&'a TextUnit> for TextRange[src]

type Output = TextRange

The resulting type after applying the - operator.

impl<'a, 'b> Sub<&'a TextUnit> for &'b TextRange[src]

type Output = TextRange

The resulting type after applying the - operator.

impl Sub<TextUnit> for TextRange[src]

type Output = TextRange

The resulting type after applying the - operator.

impl<'a> Sub<TextUnit> for &'a TextRange[src]

type Output = TextRange

The resulting type after applying the - operator.

impl<'a> SubAssign<&'a TextUnit> for TextRange[src]

impl SubAssign<TextUnit> for TextRange[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.