pub struct Data(/* private fields */);Expand description
Data is a wrapper struct for the actual data stored in memory.
It wraps a Box<dyn CloneableAny>, which allows any cloneable type to be stored in it, on the
heap. Data stored in memory must be cloneable, as we need to be able to clone it to get owned
copies when performing certain operations.
Implementations§
Source§impl Data
impl Data
Sourcepub fn new<T: Clone + 'static>(value: &T) -> Data
pub fn new<T: Clone + 'static>(value: &T) -> Data
Create a new Data struct containing a clone of the given value.
We always clone when creating new Data, since we want to have ownership over the contents, and because the lifetime of the passed value is not guaranteed to last as long as we want to.
Trait Implementations§
Source§impl AsRef<dyn CloneableAny> for Data
impl AsRef<dyn CloneableAny> for Data
Source§fn as_ref(&self) -> &dyn CloneableAny
fn as_ref(&self) -> &dyn CloneableAny
Converts this type into a shared reference of the (usually inferred) input type.
Auto Trait Implementations§
impl Freeze for Data
impl !RefUnwindSafe for Data
impl !Send for Data
impl !Sync for Data
impl Unpin for Data
impl !UnwindSafe for Data
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.