Macro impl_brand

Source
macro_rules! impl_brand {
    (
		$Brand:ident,
		$Concrete:ident,
		$KindN:ident,
		$BrandN:ident,
		()
	) => { ... };
    (
		$Brand:ident,
		$Concrete:ident,
		$KindN:ident,
		$BrandN:ident,
		($($Generics:ident),+)
	) => { ... };
}
Expand description

Generates a brand type and its BrandN trait implementation.

This macro creates a concrete brand struct and implements the appropriate kind and brand traits for it. It’s the primary way to create brand types that connect concrete types with their higher-kinded representations, enabling them to work with typeclasses.

§Parameters

  • $Brand: The name of the brand struct to generate (e.g., StringBrand, OptionBrand).
  • $Concrete: The concrete type this brand represents (e.g., String, Option).
  • $KindN: The kind trait to implement (e.g., Kind0, Kind1, Kind2).
  • $BrandN: The brand trait to implement (e.g., Brand0, Brand1, Brand2).
  • $Generics: A tuple of generic type parameters (e.g., (), (A), (A, B)).