pub struct SourceComponent<'a> { /* private fields */ }
Expand description
Provides read access to the source component (the component being cloned) in a ComponentCloneFn
.
Implementations§
Source§impl<'a> SourceComponent<'a>
impl<'a> SourceComponent<'a>
Sourcepub fn read<C: Component>(&self) -> Option<&C>
pub fn read<C: Component>(&self) -> Option<&C>
Returns a reference to the component on the source entity.
Will return None
if ComponentId
of requested component does not match ComponentId
of source component
Sourcepub fn read_reflect(&self, registry: &TypeRegistry) -> Option<&dyn Reflect>
Available on crate feature bevy_reflect
only.
pub fn read_reflect(&self, registry: &TypeRegistry) -> Option<&dyn Reflect>
bevy_reflect
only.Returns a reference to the component on the source entity as &dyn Reflect
.
Will return None
if:
- World does not have
AppTypeRegistry
. - Component does not implement
ReflectFromPtr
. - Component is not registered.
- Component does not have
TypeId
- Registered
ReflectFromPtr
’sTypeId
does not match component’sTypeId
Auto Trait Implementations§
impl<'a> Freeze for SourceComponent<'a>
impl<'a> !RefUnwindSafe for SourceComponent<'a>
impl<'a> !Send for SourceComponent<'a>
impl<'a> !Sync for SourceComponent<'a>
impl<'a> Unpin for SourceComponent<'a>
impl<'a> !UnwindSafe for SourceComponent<'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
Mutably borrows from an owned value. Read more
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>
Converts
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn 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>
Converts
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which 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)
Converts
&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)
Converts
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.