bevy_reflect

Macro impl_reflect_opaque

Source
impl_reflect_opaque!() { /* 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(opaque)] 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 opaque 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_opaque!(my_crate::Foo);
impl_reflect_opaque!(my_crate::Bar(Debug, Default, Serialize, Deserialize));

Generic types can also specify their parameters and bounds:

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

Custom type paths can be specified:

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