pub enum WidgetRef {
None,
Owned(Rc<dyn Widget>),
Borrowed(Weak<dyn Widget>),
Keyed {
owner_id: Option<WidgetId>,
key: Key,
widget: Box<WidgetRef>,
},
}
Expand description
Holds a reference to a widget, or not.
This is generally used when a widget can accept children as a parameter. It can either be Owned
,
Borrowed
, None
, or Keyed
. A Keyed
widget is one that may retain its state across parental rebuilds.
Variants§
None
No widget.
Owned(Rc<dyn Widget>)
An owned widget.
Borrowed(Weak<dyn Widget>)
A borrowed widget.
Keyed
A keyed reference which may retain its state across parental rebuilds.
Implementations§
Source§impl WidgetRef
impl WidgetRef
pub fn new<W>(widget: W) -> WidgetRefwhere
W: Widget,
pub fn try_get(&self) -> Option<Rc<dyn Widget>>
Sourcepub fn get(&self) -> Rc<dyn Widget>
pub fn get(&self) -> Rc<dyn Widget>
§Panics
Will panic if the widget no longer exists, or the reference is empty.
Sourcepub fn get_type_id(&self) -> TypeId
pub fn get_type_id(&self) -> TypeId
§Panics
Will panic if the widget no longer exists, or the reference is empty.
Sourcepub fn get_type_name(&self) -> &'static str
pub fn get_type_name(&self) -> &'static str
§Panics
Will panic if the widget no longer exists, or the reference is empty.
Sourcepub fn try_downcast_ref<W>(&self) -> Option<Rc<W>>where
W: Widget,
pub fn try_downcast_ref<W>(&self) -> Option<Rc<W>>where
W: Widget,
Returns none of the widget is not the W
type, or if it has been deallocated.
Sourcepub fn downcast_ref<W>(&self) -> Rc<W>where
W: Widget,
pub fn downcast_ref<W>(&self) -> Rc<W>where
W: Widget,
§Panics
Will panic if the widget cannot be downcasted to the generic type.
Trait Implementations§
Source§impl From<&WidgetRef> for BuildResult
impl From<&WidgetRef> for BuildResult
Source§fn from(widget: &WidgetRef) -> BuildResult
fn from(widget: &WidgetRef) -> BuildResult
Converts to this type from the input type.
Source§impl From<WidgetRef> for BuildResult
impl From<WidgetRef> for BuildResult
Source§fn from(widget: WidgetRef) -> BuildResult
fn from(widget: WidgetRef) -> BuildResult
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for WidgetRef
impl !RefUnwindSafe for WidgetRef
impl !Send for WidgetRef
impl !Sync for WidgetRef
impl Unpin for WidgetRef
impl !UnwindSafe for WidgetRef
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.