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.


Implementing TypePath on a foreign type:


On a generic type:


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


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);