#[forwardable]Expand description
This attribute primarily annotates trait definitions with forwarding information. Secondarily, it is also used to make sure that the forwarding info is properly re-exported along with the traits that it belongs to.
§Mechanism
The way that this attribute works is by defining a macro which can be used to uncurry the trait forwarding information into another macro.
Due to limitations of macro export rules, a mangled version of that macro’s name is also created and exported into the crate root. While these names are mangled so that they’re unlikely to cause name collisions, annotating trait definitions of the same name in two different modules of the same crate will definitely cause a problem. Please keep trait names within a single crate unique.
§Annotating Trait Definitions
Use on trait definitions is pretty simple. Just apply the attribute.
#[forwardable]
trait Foo
{
// ...
}The only consideration is that any types used for method arguments or associated constants should be named by their fully-qualified paths. This will prevent name-resolution errors from occurring in the macro-generated implementations.
§Annotating Re-Exports
When re-exporting a trait that has been annotated, the use statement that does the re-export should also be annotated.
mod foo
{
#[forwardable]
pub trait Foo
{
// ...
}
}
#[forwardable]
pub use foo::Foo;The forwarding information is located by modifying the path of the trait passed into the forwarding macro. If the forwarding information isn’t re-exported alongside the trait, it won’t be properly located if a path to the un-annotated re-export is used in the forwarding macro.