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§
sourcefn id(&self) -> Id
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.
sourcefn eq_id<T>(&self, rhs: T) -> bool
fn eq_id<T>(&self, rhs: T) -> bool
Test widget identifier for equality
This method may be used to test against Id
, Option<Id>
and Option<&Id>
.
sourcefn identify(&self) -> IdentifyWidget<'_>
fn identify(&self) -> IdentifyWidget<'_>
Display as “StructName#Id”
sourcefn is_ancestor_of(&self, id: &Id) -> bool
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.
sourcefn is_strict_ancestor_of(&self, id: &Id) -> bool
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.
sourcefn for_children(&self, f: impl FnMut(&dyn Layout))
fn for_children(&self, f: impl FnMut(&dyn Layout))
Run a closure on all children
sourcefn for_children_try<E>(
&self,
f: impl FnMut(&dyn Layout) -> Result<(), E>
) -> Result<(), E>
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.
sourcefn find_widget(&self, id: &Id) -> Option<&dyn Layout>
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).