Relax trait object to allow multiple ones to be passed


#1

This comes from my attempts to abstract over channels in Actix. There only one trait allowed to be boxed at a time. Strangely it can be easily workaround but it’s just additional boilerplate code:

// Not allowed
// fn foo(f: Box<Trait1 + Trait2>) {}

trait Trait1AndTrait2: Trait1 + Trait2 {}
impl<T: Trait1 + Trait2> Trait1AndTrait2 for T {}
fn foo(f: Trait1AndTrait2) {}

It would be nice to remove the boilerplate.


#2

You may find the previous discussion in Where's the catch with Box<Read + Write>?