Skip to main content

ChildrenExt

Trait ChildrenExt 

pub trait ChildrenExt: Sized {
    // Required method
    fn get_children(&mut self) -> &mut Vec<Element>;

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

Trait for composing child elements.

Required Methods§

fn get_children(&mut self) -> &mut Vec<Element>

Returns a mutable reference to the internal children vector.

§Example
impl ChildrenExt for MyElement {
    fn get_children(&mut self) -> &mut Vec<Element> {
        &mut self.elements
    }
}

Provided Methods§

fn children(self, children: impl IntoIterator<Item = Element>) -> Self

Extends the children with an iterable of Elements.

§Example
rect().children(["Hello", "World"].map(|t| label().text(t).into_element()))

fn maybe_child<C>(self, child: Option<C>) -> Self
where C: IntoElement,

Appends a child only when the Option is Some.

§Example
rect().maybe_child(show_badge.then(|| label().text("New")))

fn child<C>(self, child: C) -> Self
where C: IntoElement,

Appends a single child element.

§Example
rect().child(label().text("Hello"))

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

§

impl ChildrenExt for Accordion

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for Attached

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for Button

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for ButtonSegment

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for Canvas

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for Card

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for Chip

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for CursorArea

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for Draggable

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for DraggableCanvas

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for FloatingTab

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for ImageViewer

§

fn get_children(&mut self) -> &mut Vec<Element>

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for Menu

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for MenuButton

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for MenuContainer

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for MenuItem

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for NativeRouter

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for OverflowedContent

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for Popup

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for PopupButtons

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for PopupContent

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for ResizableDraggable

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for ResizablePanel

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for ScrollView

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for SegmentedButton

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for Select

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for SideBarItem

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for SubMenu

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for Table

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for TableBody

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for TableCell

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for TableHead

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for TableRow

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for Tile

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl ChildrenExt for TooltipContainer

§

fn get_children(&mut self) -> &mut Vec<Element>

§

impl<T> ChildrenExt for Portal<T>

§

fn get_children(&mut self) -> &mut Vec<Element>

Implementors§

§

impl ChildrenExt for Rect

§

impl ChildrenExt for Image