impl_kind

Macro impl_kind 

Source
impl_kind!() { /* proc-macro */ }
Expand description

Implements a Kind trait for a brand.

This macro simplifies the implementation of a generated Kind trait for a specific brand type. It infers the correct Kind trait to implement based on the signature of the associated types provided in the block.

The signature (names, parameters, and bounds) of the associated types must match the definition used in def_kind! or Kind! to ensure the correct trait is implemented.

§Syntax

impl_kind! {
    // Optional impl generics
    impl<Generics> for BrandType
    // Optional where clause
    where Bounds
    {
        type AssocName<Params> = ConcreteType;
        // ... more associated types
    }
}

§Examples

// Simple implementation
impl_kind! {
    for OptionBrand {
        type Of<A> = Option<A>;
    }
}

// Implementation with generics
impl_kind! {
    impl<E> for ResultBrand<E> {
        type Of<A> = Result<A, E>;
    }
}

// Implementation with where clause and multiple types
impl_kind! {
    impl<E> for MyBrand<E> where E: Clone {
        type Of<A> = MyType<A, E>;
        type SendOf<A> = MySendType<A, E>;
    }
}

// Implementation matching a `Kind` with bounds
// Corresponds to: def_kind!(type Of<T: Display>;);
impl_kind! {
    for DisplayBrand {
        // Bounds here are used to infer the correct `Kind` trait name
        type Of<T: Display> = DisplayType<T>;
    }
}