Trait LayoutExt

Source
pub trait LayoutExt: Layout {
    // Provided methods
    fn id(&self) -> Id { ... }
    fn eq_id<T>(&self, rhs: T) -> bool
       where Id: PartialEq<T> { ... }
    fn identify(&self) -> IdentifyWidget<'_> { ... }
    fn is_ancestor_of(&self, id: &Id) -> bool { ... }
    fn is_strict_ancestor_of(&self, id: &Id) -> bool { ... }
    fn for_children(&self, f: impl FnMut(&dyn Layout)) { ... }
    fn for_children_try<E>(
        &self,
        f: impl FnMut(&dyn Layout) -> Result<(), E>,
    ) -> Result<(), E> { ... }
    fn find_widget(&self, id: &Id) -> Option<&dyn Layout> { ... }
}
Expand description

Extension trait over widgets

Provided Methods§

Source

fn id(&self) -> Id

Get the widget’s identifier

Note that the default-constructed Id is invalid: any operations on this value will cause a panic. Valid identifiers are assigned during configure.

Source

fn eq_id<T>(&self, rhs: T) -> bool
where Id: PartialEq<T>,

Test widget identifier for equality

This method may be used to test against Id, Option<Id> and Option<&Id>.

Source

fn identify(&self) -> IdentifyWidget<'_>

Display as “StructName#Id”

Source

fn is_ancestor_of(&self, id: &Id) -> bool

Check whether id is self or a descendant

This function assumes that id is a valid widget.

Source

fn is_strict_ancestor_of(&self, id: &Id) -> bool

Check whether id is not self and is a descendant

This function assumes that id is a valid widget.

Source

fn for_children(&self, f: impl FnMut(&dyn Layout))

Run a closure on all children

Source

fn for_children_try<E>( &self, f: impl FnMut(&dyn Layout) -> Result<(), E>, ) -> Result<(), E>

Run a fallible closure on all children

Returns early in case of error.

Source

fn find_widget(&self, id: &Id) -> Option<&dyn Layout>

Find the descendant with this id, if any

Since id represents a path, this operation is normally O(d) where d is the depth of the path (depending on widget implementations).

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.

Implementors§

Source§

impl<W> LayoutExt for W
where W: Layout + ?Sized,