pub struct Node<'a>(/* private fields */);Expand description
Type-erased widget with input data
This type is a &mut dyn Widget<Data = A> paired with input data &A,
where the type A is erased.
The default implementation of this type uses a boxed trait object.
The unsafe_node feature enables a more efficient unboxed implementation
(this must make assumptions about VTables beyond what Rust specifies, thus
lacks even the usual programmer-provided verification of unsafe code).
Implementations§
source§impl<'a> Node<'a>
impl<'a> Node<'a>
sourcepub fn re<'b>(&'b mut self) -> Node<'b>where
'a: 'b,
pub fn re<'b>(&'b mut self) -> Node<'b>where
'a: 'b,
Reborrow with a new lifetime
Rust allows references like &T or &mut T to be “reborrowed” through
coercion: essentially, the pointer is copied under a new, shorter, lifetime.
Until rfcs#1403 lands, reborrows on user types require a method call.
sourcepub fn eq_id<T>(&self, rhs: T) -> bool
pub 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>.
sourcepub fn is_ancestor_of(&self, id: &Id) -> bool
pub 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.
sourcepub fn is_strict_ancestor_of(&self, id: &Id) -> bool
pub 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.
sourcepub fn num_children(&self) -> usize
pub fn num_children(&self) -> usize
Get the number of child widgets
Every value in the range 0..self.num_children() is a valid child
index.
sourcepub fn for_child<R>(
&mut self,
index: usize,
f: impl FnOnce(Node<'_>) -> R
) -> Option<R>
pub fn for_child<R>( &mut self, index: usize, f: impl FnOnce(Node<'_>) -> R ) -> Option<R>
Run f on some child by index and, if valid, return the result.
Calls the closure and returns Some(result) exactly when
index < self.num_children().
sourcepub fn for_children(&mut self, f: impl FnMut(Node<'_>))
pub fn for_children(&mut self, f: impl FnMut(Node<'_>))
Run a f on all children
sourcepub fn find_child_index(&self, id: &Id) -> Option<usize>
pub fn find_child_index(&self, id: &Id) -> Option<usize>
Find the child which is an ancestor of this id, if any
If Some(index) is returned, this is probably but not guaranteed
to be a valid child index.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Node<'a>
impl<'a> !Send for Node<'a>
impl<'a> !Sync for Node<'a>
impl<'a> Unpin for Node<'a>
impl<'a> !UnwindSafe for Node<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.