pub struct CharOffsetMap { /* private fields */ }Expand description
Cấu trúc hỗ trợ chuyển đổi $O(1)$ giữa UTF-8 byte offset và Unicode char offset.
Implementations§
Source§impl CharOffsetMap
impl CharOffsetMap
pub fn new(text: &str) -> Self
Sourcepub fn byte_to_char(&self, byte_offset: usize) -> usize
pub fn byte_to_char(&self, byte_offset: usize) -> usize
Trả về char offset tương ứng với byte offset.
Auto Trait Implementations§
impl Forget for CharOffsetMap
impl Freeze for CharOffsetMap
impl RefUnwindSafe for CharOffsetMap
impl Send for CharOffsetMap
impl Sync for CharOffsetMap
impl Unpin for CharOffsetMap
impl UnsafeUnpin for CharOffsetMap
impl UnwindSafe for CharOffsetMap
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more