This is a followup to 'field selector' generic? - #3 by kpreid
In particular, we have:
pub trait HasFields {
type A;
type B;
type C;
type D;
}
pub trait Select<F> {
type Out;
}
pub struct SelA;
pub struct SelB;
pub struct SelC;
pub struct SelD;
impl<T: HasFields> Select<SelA> for T { type Out = T::A; }
impl<T: HasFields> Select<SelB> for T { type Out = T::B; }
impl<T: HasFields> Select<SelC> for T { type Out = T::C; }
impl<T: HasFields> Select<SelD> for T { type Out = T::D; }
pub struct Foo<T: HasFields + Select<F>, F> {
inner: <T as Select<F>>::Out,
}
I want to say pub struct Bar<T> ... { ... }
conditioned on Select<T>
being implemented. Is there a way to add this constraint ?