pub struct TextRange {
pub start: i32,
pub end: i32,
}Expand description
A range of characters in a string of text.
Fields§
§start: i32The index of the first character in the range.
end: i32The next index after the characters in this range.
Implementations§
Source§impl TextRange
impl TextRange
Sourcepub const fn new(start: i32, end: i32) -> TextRange
pub const fn new(start: i32, end: i32) -> TextRange
Creates a new TextRange. The start and end must be at least -1.
Sourcepub fn is_collapsed(&self) -> bool
pub fn is_collapsed(&self) -> bool
Whether this range is empty (but still potentially placed inside the text).
Sourcepub fn is_normalized(&self) -> bool
pub fn is_normalized(&self) -> bool
Whether the start of this range precedes the end.
Sourcepub fn text_before<'a>(&self, text: &'a str) -> &'a str
pub fn text_before<'a>(&self, text: &'a str) -> &'a str
The text before this range.
Sourcepub fn text_after<'a>(&self, text: &'a str) -> &'a str
pub fn text_after<'a>(&self, text: &'a str) -> &'a str
The text after this range.
Sourcepub fn text_inside<'a>(&self, text: &'a str) -> &'a str
pub fn text_inside<'a>(&self, text: &'a str) -> &'a str
The text inside this range.
Trait Implementations§
impl Copy for TextRange
impl Eq for TextRange
Source§impl From<TextSelection> for TextRange
impl From<TextSelection> for TextRange
Source§fn from(selection: TextSelection) -> TextRange
fn from(selection: TextSelection) -> TextRange
Converts to this type from the input type.
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 UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.