bevy/crates/bevy_reflect/bevy_reflect_derive/src
Gino Valente 02fbf16c80 bevy_reflect: Add Reflect::into_reflect (#6502)
# 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`
2022-11-07 02:11:16 +00:00
..
impls bevy_reflect: Add Reflect::into_reflect (#6502) 2022-11-07 02:11:16 +00:00
container_attributes.rs Use new let-else syntax where possible (#6463) 2022-11-04 21:32:09 +00:00
derive_data.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
documentation.rs fix nightly clippy warnings (#6395) 2022-10-28 21:03:01 +00:00
enum_utility.rs Add reflect(skip_serializing) which retains reflection but disables automatic serialization (#5250) 2022-09-19 16:12:10 +00:00
field_attributes.rs Add reflect(skip_serializing) which retains reflection but disables automatic serialization (#5250) 2022-09-19 16:12:10 +00:00
from_reflect.rs bevy_reflect: Reflect enums (#4761) 2022-08-02 22:14:41 +00:00
lib.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
reflect_value.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
registration.rs fix nightly clippy warnings (#6395) 2022-10-28 21:03:01 +00:00
trait_reflection.rs bevy_reflect: Added get_boxed method to reflect_trait (#4120) 2022-05-20 13:31:49 +00:00
type_uuid.rs Use new let-else syntax where possible (#6463) 2022-11-04 21:32:09 +00:00
utility.rs fix nightly clippy warnings (#6395) 2022-10-28 21:03:01 +00:00