pub struct Utf16Mapping { /* private fields */ }Expand description
Bidirectional UTF-8 byte offset ↔ UTF-16 code unit offset mapping.
Implementations§
Source§impl Utf16Mapping
impl Utf16Mapping
pub fn new(text: &str) -> Self
Sourcepub fn byte_to_utf16(&self, byte_offset: usize) -> Result<usize, TextViewError>
pub fn byte_to_utf16(&self, byte_offset: usize) -> Result<usize, TextViewError>
Convert a UTF-8 byte offset to a UTF-16 code unit offset.
Sourcepub fn utf16_to_byte(&self, utf16_offset: usize) -> Result<usize, TextViewError>
pub fn utf16_to_byte(&self, utf16_offset: usize) -> Result<usize, TextViewError>
Convert a UTF-16 code unit offset to a UTF-8 byte offset.
Trait Implementations§
Source§impl Clone for Utf16Mapping
impl Clone for Utf16Mapping
Source§fn clone(&self) -> Utf16Mapping
fn clone(&self) -> Utf16Mapping
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for Utf16Mapping
impl RefUnwindSafe for Utf16Mapping
impl Send for Utf16Mapping
impl Sync for Utf16Mapping
impl Unpin for Utf16Mapping
impl UnsafeUnpin for Utf16Mapping
impl UnwindSafe for Utf16Mapping
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