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 new<T>(widget: &'a mut dyn Widget<Data = T>, data: &'a T) -> Node<'a>where
T: 'a,
pub fn new<T>(widget: &'a mut dyn Widget<Data = T>, data: &'a T) -> Node<'a>where
T: 'a,
Construct
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> Freeze for Node<'a>
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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
.Source§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
.Source§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.Source§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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more