[][src]Struct vgtk::VNodeIterator

pub struct VNodeIterator<Model: Component> { /* fields omitted */ }

An iterator over zero or one VNodes.

A VNode implements IntoIterator to build a VNodeIterator, so you can return a single VNode in a code block in the gtk! macro without needing to convert it.

If you need to return an empty list of VNodes, use VNode::empty().

This iterator mainly exists to enable the pattern of conditionally returning a node from an if expression, because the empty iterator and the single node iterator both have the same type, unlike if you attempted to return std::iter::once() and std::iter::empty(), which would result in a type error.

Examples

let render_label: bool = should_render_label();
gtk! {
    <Box::new(Orientation::Vertical, 10)>
        {
            if render_label {
                (gtk! { <Label label="It's a me, Label!" /> }).into_iter()
            } else {
                VNode::empty()
            }
        }
    </Box>
}

Trait Implementations

impl<Model: Component> Iterator for VNodeIterator<Model>[src]

type Item = VNode<Model>

The type of the elements being iterated over.

Auto Trait Implementations

impl<Model> !RefUnwindSafe for VNodeIterator<Model>

impl<Model> !Send for VNodeIterator<Model>

impl<Model> !Sync for VNodeIterator<Model>

impl<Model> Unpin for VNodeIterator<Model>

impl<Model> !UnwindSafe for VNodeIterator<Model>

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.