Apply

Macro Apply 

Source
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.

§Syntax

Apply!(<Brand as Kind!( KindSignature )>::AssocType<Args>)
  • Brand: The brand type (e.g., OptionBrand).
  • KindSignature: A list of associated type definitions defining the Kind trait schema.
  • AssocType: The associated type to project (e.g., Of).
  • Args: The concrete arguments to apply.

§Examples

// Applies MyBrand to lifetime 'static and type String.
type Concrete = Apply!(<MyBrand as Kind!( type Of<'a, T>; )>::Of<'static, String>);

// Applies MyBrand to a generic type T with bounds.
type Concrete = Apply!(<MyBrand as Kind!( type Of<T: Clone>; )>::Of<T>);

// Complex example with lifetimes, types, and output bounds.
type Concrete = Apply!(<MyBrand as Kind!( type Of<'a, T: Clone + Debug>: Display; )>::Of<'a, T>);

// Use a custom associated type for projection.
type Concrete = Apply!(<MyBrand as Kind!( type Of<T>; type SendOf<T>; )>::SendOf<T>);