use disjoint_impls::disjoint_impls; pub trait Dispatch { type Group: ?Sized; } pub enum GroupA {} impl Dispatch for Option { type Group = GroupA; } impl Dispatch for Option { type Group = GroupA; } pub struct GroupB; impl Dispatch for Option> { type Group = GroupB; } disjoint_impls! { pub trait Kita { const NAME: &'static str; } impl Kita for T where Option: Dispatch { const NAME: &'static str = "Blanket A"; } impl Kita for Vec where Option>: Dispatch { const NAME: &'static str = "Blanket B"; } impl Kita for Option where Option: Dispatch { const NAME: &'static str = "Blanket C"; } } /* pub trait Kita { const NAME: &'static str; } const _: () = { pub trait _Kita0<_0: ?Sized> { const NAME: &'static str; } pub trait _Kita1<_0: ?Sized> { const NAME: &'static str; } impl<_0> _Kita0 for _0 where Option<_0>: Dispatch { const NAME: &'static str = "Blanket A"; } impl<_0> _Kita0 for Vec<_0> where Option>: Dispatch { const NAME: &'static str = "Blanket B"; } impl<_0> _Kita1 for Option<_0> where Option<_0>: Dispatch { const NAME: &'static str = "Blanket C"; } impl<_0> Kita for _0 where Option<_0>: Dispatch, Self: _Kita0< as Dispatch>::Group> { const NAME: &'static str = as Dispatch>::Group>>::NAME; } impl<_0> Kita for Option<_0> where Option<_0>: Dispatch, Self: _Kita1< as Dispatch>::Group> { const NAME: &'static str = as Dispatch>::Group>>::NAME; } }; */ fn supersets() { assert_eq!("Blanket A", String::NAME); assert_eq!("Blanket B", Vec::::NAME); assert_eq!("Blanket C", Option::::NAME); assert_eq!("Blanket A", u32::NAME); assert_eq!("Blanket B", Vec::::NAME); assert_eq!("Blanket C", Option::::NAME); }