use disjoint_impls::disjoint_impls; pub trait Dispatch { type Group; } pub enum GroupA {} impl Dispatch for String { type Group = GroupA; } impl Dispatch for Vec { type Group = GroupA; } pub enum GroupB {} impl Dispatch for i32 { type Group = GroupB; } impl Dispatch for u32 { type Group = GroupB; } disjoint_impls! { pub trait Kita { const NAME: &'static str; } impl Kita for T where U: Dispatch { const NAME: &'static str = "Blanket A"; } impl> Kita for T { const NAME: &'static str = "Blanket B"; } } /* pub trait Kita { const NAME: &'static str; } const _: () = { pub trait _Kita0<_1: ?Sized, U> { const NAME: &'static str; } impl<_1, _0> _Kita0 for _1 where _0: Dispatch { const NAME: &'static str = "Blanket A"; } impl<_1, _0: Dispatch> _Kita0 for _1 { const NAME: &'static str = "Blanket B"; } impl<_0, _1> Kita<_0> for _1 where _0: Dispatch, Self: _Kita0<<_0 as Dispatch>::Group, _0> { const NAME: &'static str = ::Group, _0>>::NAME; } }; */ #[test] fn dispatch_on_different_parameters() { assert_eq!("Blanket A", >::NAME); assert_eq!("Blanket B", as Kita>::NAME); assert_eq!("Blanket B", >::NAME); assert_eq!("Blanket B", >::NAME); }