[][src]Struct render_tree::Each

pub struct Each<U, Iterator: IntoIterator<Item = U>> {
    pub items: Iterator,
}

A list of items that can be appended into a Document. For each item in items, the callback is invoked, and its return value is appended to the document.

Example

struct Point(i32, i32);

let items = vec![Point(10, 20), Point(5, 10), Point(6, 42)];

let document = Document::with(Each(
    &items,
    |item, doc| doc.add(Line("Point(".add(item.0).add(",").add(item.1).add(")")))
));

assert_eq!(document.to_string()?, "Point(10,20)\nPoint(5,10)\nPoint(6,42)\n");

And with the tree! macro:

struct Point(i32, i32);

let items = vec![Point(10, 20), Point(5, 10), Point(6, 42)];

let document = tree! {
    <Each items={items} as |item| {
        <Line as {
            "Point(" {item.0} "," {item.1} ")"
        }>
    }>
};

assert_eq!(document.to_string()?, "Point(10,20)\nPoint(5,10)\nPoint(6,42)\n");

Fields

items: Iterator

Trait Implementations

impl<U, Iterator: IntoIterator<Item = U>> IterBlockComponent for Each<U, Iterator>
[src]

type Item = U

fn with<F: FnMut(Self::Item, Document) -> Document>(
    component: Self,
    block: F
) -> CurriedIterBlockComponent<Self, F>
[src]

impl<U, I: IntoIterator<Item = U>> From<I> for Each<U, I>
[src]

Auto Trait Implementations

impl<U, Iterator> Send for Each<U, Iterator> where
    Iterator: Send

impl<U, Iterator> Sync for Each<U, Iterator> where
    Iterator: Sync

Blanket Implementations

impl<T> From for T
[src]

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

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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