IMHO, Rust just should take size of the largest implementation of Animal for `impl Animal`, and viola — we can make them static. No heap is good for embedded.
trait Foo { fn foo(); }
impl<T> Foo for T {
fn foo() {
<Box<T> as Foo>::foo();
}
}
...but the compiler can't compile it: since Rust implements generics solely through monomorphization, that would require generating an infinitely large binary :)That doesn't sound right. Trait objects use dynamic dispatch.