bevy_reflect

Macro impl_type_path

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

A replacement for deriving TypePath for use on foreign types.

Since (unlike the derive) this macro may be invoked in a different module to where the type is defined, it requires an ‘absolute’ path definition.

Specifically, a leading :: denoting a global path must be specified or a preceding (in my_crate::foo) to specify the custom path must be used.

§Examples

Implementing TypePath on a foreign type:

impl_type_path!(::foreign_crate::foo::bar::Baz);

On a generic type (this can also accept trait bounds):

impl_type_path!(::foreign_crate::Foo<T>);
impl_type_path!(::foreign_crate::Goo<T: ?Sized>);

On a primitive (note this will not compile for a non-primitive type):

impl_type_path!(bool);

With a custom type path:

impl_type_path!((in other_crate::foo::bar) Baz);

With a custom type path and a custom type name:

impl_type_path!((in other_crate::foo as Baz) Bar);