mirror of
https://github.com/bevyengine/bevy
synced 2024-11-23 13:13:49 +00:00
02fbf16c80
# Objective Using `Reflect` we can easily switch between a specific reflection trait object, such as a `dyn Struct`, to a `dyn Reflect` object via `Reflect::as_reflect` or `Reflect::as_reflect_mut`. ```rust fn do_something(value: &dyn Reflect) {/* ... */} let foo: Box<dyn Struct> = Box::new(Foo::default()); do_something(foo.as_reflect()); ``` However, there is no way to convert a _boxed_ reflection trait object to a `Box<dyn Reflect>`. ## Solution Add a `Reflect::into_reflect` method which allows converting a boxed reflection trait object back into a boxed `Reflect` trait object. ```rust fn do_something(value: Box<dyn Reflect>) {/* ... */} let foo: Box<dyn Struct> = Box::new(Foo::default()); do_something(foo.into_reflect()); ``` --- ## Changelog - Added `Reflect::into_reflect` |
||
---|---|---|
.. | ||
impls | ||
container_attributes.rs | ||
derive_data.rs | ||
documentation.rs | ||
enum_utility.rs | ||
field_attributes.rs | ||
from_reflect.rs | ||
lib.rs | ||
reflect_value.rs | ||
registration.rs | ||
trait_reflection.rs | ||
type_uuid.rs | ||
utility.rs |