[−][src]Macro syllogism::define_compatibility
A macro to define traits and other macros that help to implement IsNot
and Specialize
across crates.
The macro expects the dollar symbol (for technical reasons), followed by a comma-separated list of (trait, macro) pairs. Note that the trailing comma after the last pair is mandatory. The macro expands to definitions of these traits and macros.
Example
define_compatibility!( $ (NotInCrate1, macro_for_crate1), (NotInCrate2, macro_for_crate2), (NotInCrate3, macro_for_crate3), );
This expands to the following:
trait NotInCrate1 {} trait NotInCrate2 {} trait NotInCrate3 {} macro_rules! macro_for_crate1 { // See below for more information. } macro_rules! macro_for_crate2 { // See below for more information. } macro_rules! macro_for_crate3 { // See below for more information. }
The generated macros can in turn be used in the following way:
struct MyStruct { // ... } struct MyGenericStruct<T> { // ... } macro_for_crate1!(impl trait for MyStruct {}); macro_for_crate1!(impl<T> trait for MyGenericStruct<T> {});
This expands to the following:
impl NotInCrate2 for MyStruct {} impl NotInCrate3 for MyStruct {} impl<T> NotInCrate2 for MyGenericStruct<T> {} impl<T> NotInCrate3 for MyGenericStruct<T> {}