Kind!() { /* proc-macro */ }Expand description
Generates the name of a Kind trait based on its signature.
This macro takes a list of associated type definitions, similar to a trait definition.
§Syntax
ⓘ
Kind!(
type AssocName<Params>: Bounds;
// ...
)§Parameters
Associated Types: A list of associated type definitions (e.g.,type Of<T>;) that define the signature of the Kind.
§Generates
The name of the generated Kind trait (e.g., Kind_0123456789abcdef).
The name is deterministic and based on a hash of the signature.
§Examples
ⓘ
// Invocation
let name = Kind!(type Of<T>;);
// Expanded code
let name = Kind_...; // e.g., Kind_a1b2c3d4e5f67890ⓘ
// Invocation
let name = Kind!(type Of<'a, T: Display>: Debug;);
// Expanded code
let name = Kind_...; // Unique hash based on signatureⓘ
// Invocation
let name = Kind!(
type Of<T>;
type SendOf<T>: Send;
);
// Expanded code
let name = Kind_...; // Unique hash based on signature§Limitations
Due to Rust syntax restrictions, this macro cannot be used directly in positions where a concrete path is expected by the parser, such as:
- Supertrait bounds:
trait MyTrait: Kind!(...) {}(Invalid) - Type aliases:
type MyKind = Kind!(...);(Invalid) - Trait aliases:
trait MyKind = Kind!(...);(Invalid)
In these cases, you must use the generated name directly (e.g., Kind_...).