[][src]Struct xi_unicode::LineBreakLeafIter

pub struct LineBreakLeafIter { /* fields omitted */ }

A class (TODO, not right word) useful for computing line breaks in a rope or other non-contiguous string representation. This is a trickier problem than iterating in a string for a few reasons, the trickiest of which is that in the general case, line breaks require an indeterminate amount of look-behind.

This is something of an "expert-level" interface, and should only be used if the caller is prepared to respect all the invariants. Otherwise, you might get inconsistent breaks depending on start positiona and leaf boundaries.

Implementations

impl LineBreakLeafIter[src]

pub fn new(s: &str, ix: usize) -> LineBreakLeafIter[src]

Create a new line break iterator suitable for leaves in a rope. Precondition: ix is at a code point boundary within s.

pub fn next(&mut self, s: &str) -> (usize, bool)[src]

Return break pos and whether it's a hard break. Note: hard break indication may go away, this may not be useful in actual application. If end of leaf is found, return leaf's len. This does not indicate a break, as that requires at least one more codepoint of context. If it is a break, then subsequent next call will return an offset of 0. EOT is always a break, so in the EOT case it's up to the caller to figure that out.

For consistent results, always supply same s until end of leaf is reached (and initially this should be the same as in the new call).

Trait Implementations

impl Clone for LineBreakLeafIter[src]

impl Copy for LineBreakLeafIter[src]

impl Default for LineBreakLeafIter[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.