-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Implement Reflect for Box<dyn Reflect> #3392
Copy link
Copy link
Open
Labels
A-ReflectionRuntime information about typesRuntime information about typesC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useD-ComplexQuite challenging from either a design or technical perspective. Ask for help!Quite challenging from either a design or technical perspective. Ask for help!S-Waiting-on-SMEThis is currently waiting for an SME to resolve something controversialThis is currently waiting for an SME to resolve something controversial
Description
What problem does this solve or what need does it fill?
Boxed Reflect trait objects should themselves be reflectable
What solution would you like?
Implement Reflect for Box<dyn Reflect>.
What alternative(s) have you considered?
None.
Additional context
Working snippet from @Davier:
unsafe impl Reflect for Box<dyn Reflect> {
fn type_name(&self) -> &str {
self.deref().type_name()
}
fn any(&self) -> &dyn Any {
self.deref().any()
}
fn any_mut(&mut self) -> &mut dyn Any {
self.deref_mut().any_mut()
}
fn apply(&mut self, value: &dyn Reflect) {
self.deref_mut().apply(value)
}
fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>> {
self.deref_mut().set(value)
}
fn reflect_ref(&self) -> ReflectRef {
self.deref().reflect_ref()
}
fn reflect_mut(&mut self) -> ReflectMut {
self.deref_mut().reflect_mut()
}
fn clone_value(&self) -> Box<dyn Reflect> {
self.deref().clone_value()
}
fn reflect_hash(&self) -> Option<u64> {
self.deref().reflect_hash()
}
fn reflect_partial_eq(&self, value: &dyn Reflect) -> Option<bool> {
self.deref().reflect_partial_eq(value)
}
fn serializable(&self) -> Option<Serializable> {
self.deref().serializable()
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-ReflectionRuntime information about typesRuntime information about typesC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useD-ComplexQuite challenging from either a design or technical perspective. Ask for help!Quite challenging from either a design or technical perspective. Ask for help!S-Waiting-on-SMEThis is currently waiting for an SME to resolve something controversialThis is currently waiting for an SME to resolve something controversial