pub struct TextPosition(/* private fields */);Expand description
A validated UTF-8 byte position in a particular text value.
Implementations§
Source§impl TextPosition
impl TextPosition
pub const START: Self
Sourcepub fn from_utf8(text: &str, offset: usize) -> Result<Self, TextOffsetError>
pub fn from_utf8(text: &str, offset: usize) -> Result<Self, TextOffsetError>
Validates a canonical UTF-8 byte offset for text.
Sourcepub fn from_utf16(text: &str, offset: usize) -> Result<Self, TextOffsetError>
pub fn from_utf16(text: &str, offset: usize) -> Result<Self, TextOffsetError>
Converts and validates a platform UTF-16 code-unit offset.
Sourcepub fn from_scalar_offset(
text: &str,
offset: usize,
) -> Result<Self, TextOffsetError>
pub fn from_scalar_offset( text: &str, offset: usize, ) -> Result<Self, TextOffsetError>
Converts a Unicode scalar-value index used by accessibility APIs.
pub fn at_end(text: &str) -> Self
pub const fn utf8_offset(self) -> usize
pub fn utf16_offset(self, text: &str) -> Result<usize, TextOffsetError>
pub fn scalar_offset(self, text: &str) -> Result<usize, TextOffsetError>
pub fn is_grapheme_boundary(self, text: &str) -> bool
pub fn floor(text: &str, offset: usize) -> Self
Trait Implementations§
Source§impl Clone for TextPosition
impl Clone for TextPosition
Source§fn clone(&self) -> TextPosition
fn clone(&self) -> TextPosition
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for TextPosition
Source§impl Debug for TextPosition
impl Debug for TextPosition
Source§impl Default for TextPosition
impl Default for TextPosition
Source§fn default() -> TextPosition
fn default() -> TextPosition
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for TextPosition
impl<'de> Deserialize<'de> for TextPosition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for TextPosition
Source§impl Hash for TextPosition
impl Hash for TextPosition
Source§impl Ord for TextPosition
impl Ord for TextPosition
Source§fn cmp(&self, other: &TextPosition) -> Ordering
fn cmp(&self, other: &TextPosition) -> Ordering
1.21.0 (const: unstable) · Source§fn 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
Source§impl PartialEq for TextPosition
impl PartialEq for TextPosition
Source§impl PartialOrd for TextPosition
impl PartialOrd for TextPosition
Source§impl Serialize for TextPosition
impl Serialize for TextPosition
impl StructuralPartialEq for TextPosition
Auto Trait Implementations§
impl Freeze for TextPosition
impl RefUnwindSafe for TextPosition
impl Send for TextPosition
impl Sync for TextPosition
impl Unpin for TextPosition
impl UnsafeUnpin for TextPosition
impl UnwindSafe for TextPosition
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.