The problem is that the f method is not object-safe, because it is general, and therefore it cannot be called on the object-object. You will have to force your users to close in the box:
trait A { fn f(&self, p: Box<Fn() -> ()>); }
I wonder why Rust allows Box<A> in the first place, I would expect an error there. And this particular mistake is really misleading. I would make a mistake about it.
Alternatively, you can discard feature objects in favor of regular limited generics, although this is not always possible.
source share