I'm wondering how to make the following work assuming I can't change function signatures. This fails to compile with &Outer
defined as &Box
, &Rc
, &Arc
, &&
, etc. but works if I employ my own type &A
. I tried enabling feature(arbitrary_self_types)
to see if this behavior is related, but that didn't seem to make a difference.
struct A<T: ?Sized>(T);
struct B;
// works
// type Outer<T> = A<T>;
// does not work
type Outer<T> = Box<T>;
trait MyTrait {}
impl MyTrait for B {}
fn foo(x: &Outer<B>) {
bar(x);
}
fn bar(x: &Outer<dyn MyTrait>){}