Broken error message? "(expected &Foo, found &Foo)"

As a follow-up brought up by thinking about @vitalyd's post, note that for your example to work with the kind of blanket impl that I suggested, you will need to implement FooDefault for dynamically sized types too:

impl<T: Foo + ?Sized> FooDefault for T {}

I wrote a deeper discussion of what this syntax means and why it is needed elsewhere.

In your particular case, though, requesting the type to implement FooDefault before using xx() would probably be a simpler and equally valid strategy.

1 Like