[][src]Struct cansi::CategorisedLineIterator

pub struct CategorisedLineIterator<'text, 'iter> { /* fields omitted */ }

An iterator structure for CategorisedSlices, iterating over each new line (\n or \r\n) and returns the categorised slices within those. CategorisedSlices that include a new line are split with the same style.

Example


let s = format!("{}{}\nhow are you\r\ntoday", "hello, ".green(), "world".red());
let cat = categorise_text(&s);
let mut iter = line_iter(&cat);

let first = iter.next().unwrap();
assert_eq!(first[0].text, "hello, ");
assert_eq!(first[0].fg_colour, Color::Green);

assert_eq!(first[1].text, "world");
assert_eq!(first[1].fg_colour, Color::Red);

assert_eq!(&construct_text_no_codes(&iter.next().unwrap()), "how are you");
assert_eq!(&construct_text_no_codes(&iter.next().unwrap()), "today");
assert_eq!(iter.next(), None);

Trait Implementations

impl<'text, 'iter> Iterator for CategorisedLineIterator<'text, 'iter>[src]

type Item = CategorisedLine<'text>

The type of the elements being iterated over.

Auto Trait Implementations

impl<'text, 'iter> RefUnwindSafe for CategorisedLineIterator<'text, 'iter>

impl<'text, 'iter> Send for CategorisedLineIterator<'text, 'iter>

impl<'text, 'iter> Sync for CategorisedLineIterator<'text, 'iter>

impl<'text, 'iter> Unpin for CategorisedLineIterator<'text, 'iter> where
    'text: 'iter, 

impl<'text, 'iter> UnwindSafe for CategorisedLineIterator<'text, 'iter>

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<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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.