bevy/crates/bevy_reflect/src/enums
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
..
dynamic_enum.rs bevy_reflect: Add Reflect::into_reflect (#6502) 2022-11-07 02:11:16 +00:00
enum_trait.rs bevy_reflect: Binary formats (#6140) 2022-11-04 02:22:54 +00:00
helpers.rs Use new let-else syntax where possible (#6463) 2022-11-04 21:32:09 +00:00
mod.rs Add reflect(skip_serializing) which retains reflection but disables automatic serialization (#5250) 2022-09-19 16:12:10 +00:00
variants.rs bevy_reflect: Binary formats (#6140) 2022-11-04 02:22:54 +00:00