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).
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.