Skip to main content

ParentElement

Trait ParentElement 

Source
pub trait ParentElement {
    // Required method
    fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>);

    // Provided methods
    fn child(self, child: impl IntoElement) -> Self
       where Self: Sized { ... }
    fn children(
        self,
        children: impl IntoIterator<Item = impl IntoElement>,
    ) -> Self
       where Self: Sized { ... }
}
Expand description

An element that can hold any number of children of any type.

This is the trait behind .child() and .children() on containers such as div. Each child is anything that implements IntoElement, so strings, views and other elements can be mixed in one container.

Required Methods§

Source

fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>)

Adds the given children to the end of this element’s children.

Provided Methods§

Source

fn child(self, child: impl IntoElement) -> Self
where Self: Sized,

Adds one child to this element, and returns the element for chaining.

Source

fn children(self, children: impl IntoIterator<Item = impl IntoElement>) -> Self
where Self: Sized,

Adds several children to this element, in iteration order, and returns the element.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§