Crate disjoint_impls

Crate disjoint_impls 

Source
Expand description

Unlock support for a variety of mutually disjoint implementations that the Rust compiler does not (yet?) support.

Works for trait and inherent implementations alike (no special syntax).

§Trait implementations

use disjoint_impls::disjoint_impls;

pub trait Dispatch {
    type Group;
}

disjoint_impls! {
    pub trait Kita {}

    impl<T: Dispatch<Group = u32>> Kita for T {}
    impl<T: Dispatch<Group = i32>> Kita for T {}
}

§Inherent implementations

use disjoint_impls::disjoint_impls;

pub trait Dispatch {
    type Group;
}

struct Wrapper<T>(T);

disjoint_impls! {
    impl<T: Dispatch<Group = u32>> Wrapper<T> {}
    impl<T: Dispatch<Group = i32>> Wrapper<T> {}
}

See the disjoint_impls! macro for details.

Macros§

disjoint_impls
Enables writing non-overlapping (disjoint) impls distinguished by a set of associated types.