Function unicode_linebreak::linebreaks[][src]

pub fn linebreaks<'a>(
    s: &'a str
) -> impl Iterator<Item = (usize, BreakOpportunity)> + Clone + 'a
Expand description

Returns an iterator over line break opportunities in the specified string.

Break opportunities are given as tuples of the byte index of the character succeeding the break and the type.

Uses the default Line Breaking Algorithm with the tailoring that Complex-Context Dependent (SA) characters get resolved to Ordinary Alphabetic and Symbol Characters (AL) regardless of General_Category.

Examples

use unicode_linebreak::{linebreaks, BreakOpportunity::{Mandatory, Allowed}};
assert!(linebreaks("Hello world!").eq(vec![(6, Allowed), (12, Mandatory)]));