Enum agui::Ref [−][src]
Expand description
Holds a reference that is either None
, Owned
, or Borrowed
.
It’s used to give a single field that can accept Option
(without additional wrapping),
an owned value, or a reference to an owned value (to prevent unnecessary clones).
Example
pub struct Button {
// Allows the Button to provide its own default, accept an owned value from a parent
// widget, or a reference to a layout.
pub layout: Ref<Layout>,
}
Variants
None
No value.
Owned(Arc<V>)
Tuple Fields
0: Arc<V>
Owned data.
Borrowed(Weak<V>)
Tuple Fields
0: Weak<V>
Borrowed data. Unlike Owned, this is not guaranteed to exist, as it only holds a weak reference to the Owned value. It should never be expected for the value to exist.
Implementations
Returns true if this reference points to a value in memory.
Will always be true
if the Ref is Owned
, will always be None
if the Ref is None
,
but if it’s Borrowed
, it will only return true
if the borrowed value is still in memory.
Attempst to fetch the value that this reference is wrapping.
Trait Implementations
Auto Trait Implementations
impl<V: ?Sized> RefUnwindSafe for Ref<V> where
V: RefUnwindSafe,
impl<V: ?Sized> UnwindSafe for Ref<V> where
V: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: 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
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub 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. Read more