Apply!() { /* proc-macro */ }Expand description
Applies a brand to type arguments.
This macro projects a brand type to its concrete type using the appropriate
Kind trait. It uses a syntax that mimics a fully qualified path, where the
Kind trait is specified by its signature.
InferableBrand!(SIG) invocations within the brand position are resolved
automatically via preprocessing, enabling readable signatures like:
Apply!(<<FA as InferableBrand!(type Of<'a, A: 'a>: 'a;)>::Brand as Kind!(...)>::Of<'a, B>)
§Syntax
ⓘ
Apply!(<Brand as Kind!( KindSignature )>::AssocType<Args>)Brand: The brand type (e.g.,OptionBrand). May containInferableBrand!(SIG)invocations.KindSignature: A list of associated type definitions defining theKindtrait schema.AssocType: The associated type to project (e.g.,Of).Args: The concrete arguments to apply.
§Generates
The concrete type resulting from applying the brand to the arguments.
§Examples
ⓘ
// Invocation
// Applies MyBrand to lifetime 'static and type String.
type Concrete = Apply!(<MyBrand as Kind!( type Of<'a, T>; )>::Of<'static, String>);
// Expanded code
type Concrete = <MyBrand as Kind_...>::Of<'static, String>;ⓘ
// Invocation
// Applies MyBrand to a generic type T with bounds.
type Concrete = Apply!(<MyBrand as Kind!( type Of<T: Clone>; )>::Of<T>);
// Expanded code
type Concrete = <MyBrand as Kind_...>::Of<T>;ⓘ
// Invocation
// Complex example with lifetimes, types, and output bounds.
type Concrete = Apply!(<MyBrand as Kind!( type Of<'a, T: Clone + Debug>: Display; )>::Of<'a, T>);
// Expanded code
type Concrete = <MyBrand as Kind_...>::Of<'a, T>;ⓘ
// Invocation
// Use a custom associated type for projection.
type Concrete = Apply!(<MyBrand as Kind!( type Of<T>; type SendOf<T>; )>::SendOf<T>);
// Expanded code
type Concrete = <MyBrand as Kind_...>::SendOf<T>;ⓘ
// InferableBrand! in the brand position (resolved via preprocessing)
Apply!(<<FA as InferableBrand!(type Of<'a, A: 'a>: 'a;)>::Brand as Kind!(type Of<'a, T: 'a>: 'a;)>::Of<'a, B>)
// Expanded code (InferableBrand! resolved to InferableBrand_cdc7...)
<FA as InferableBrand_cdc7...>::Brand as Kind_cdc7...>::Of<'a, B>