pub struct JoinedRunSegmenter;Expand description
Splits text into runs of joined letters.
Returns boundary offsets, including 0 and the end of the string. An empty string has one boundary, at 0.
§Example
use kashida::JoinedRunSegmenter;
let text = "خط الزوال";
let boundaries: Vec<usize> = JoinedRunSegmenter::new().segment_str(text).collect();
let runs: Vec<&str> = boundaries.windows(2).map(|w| &text[w[0]..w[1]]).collect();
assert_eq!(runs, ["خط", " ", "ا", "لز", "و", "ا", "ل"]);Implementations§
Source§impl JoinedRunSegmenter
impl JoinedRunSegmenter
Sourcepub fn segment_str(self, input: &str) -> impl Iterator<Item = usize>
pub fn segment_str(self, input: &str) -> impl Iterator<Item = usize>
Returns joined run boundaries as UTF-8 byte offsets.
Sourcepub fn segment_utf16(self, input: &[u16]) -> impl Iterator<Item = usize>
pub fn segment_utf16(self, input: &[u16]) -> impl Iterator<Item = usize>
Returns joined run boundaries as UTF-16 code unit offsets.
Unpaired surrogates are treated as U+FFFD (the replacement character).
Trait Implementations§
Source§impl Clone for JoinedRunSegmenter
impl Clone for JoinedRunSegmenter
impl Copy for JoinedRunSegmenter
Source§impl Debug for JoinedRunSegmenter
impl Debug for JoinedRunSegmenter
Auto Trait Implementations§
impl Freeze for JoinedRunSegmenter
impl RefUnwindSafe for JoinedRunSegmenter
impl Send for JoinedRunSegmenter
impl Sync for JoinedRunSegmenter
impl Unpin for JoinedRunSegmenter
impl UnsafeUnpin for JoinedRunSegmenter
impl UnwindSafe for JoinedRunSegmenter
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