bevy_reflect

Macro impl_reflect_value

Source
impl_reflect_value!() { /* proc-macro */ }
Expand description

A macro used to generate reflection trait implementations for the given type.

This is functionally the same as deriving Reflect using the #[reflect_value] container attribute.

The only reason for this macro’s existence is so that bevy_reflect can easily implement the reflection traits on primitives and other Rust types internally.

Since this macro also implements TypePath, the type path must be explicit. See impl_type_path! for the exact syntax.

§Examples

Types can be passed with or without registering type data:

impl_reflect_value!(my_crate::Foo);
impl_reflect_value!(my_crate::Bar(Debug, Default, Serialize, Deserialize));

Generic types can also specify their parameters and bounds:

impl_reflect_value!(my_crate::Foo<T1, T2: Baz> where T1: Bar (Default, Serialize, Deserialize));

Custom type paths can be specified:

impl_reflect_value!((in not_my_crate as NotFoo) Foo(Debug, Default));