Skip to main content

grapheme_cells

Function grapheme_cells 

Source
pub fn grapheme_cells(
    s: &str,
    mode: WidthMode,
    eaw_wide: bool,
) -> impl Iterator<Item = (&str, u8)>
Expand description

Iterate s as (grapheme_cluster, width) pairs.

Segmentation is always by extended grapheme cluster. Width calculation uses WidthMode::grapheme_width with the supplied East-Asian Ambiguous policy. The string slice in each yielded pair borrows from s.

§Parameters

  • s — UTF-8 string to segment and measure.
  • mode — cluster-width policy.
  • eaw_wide — East-Asian Ambiguous policy.

§Returns

An iterator yielding borrowed cluster slices and their display widths.

§Errors and panics

This function does not fail or intentionally panic.