Hello,
Why do we need 2 functions for either static or dynamic dispatch ?
Let's say I have a function for static dispatch
fn <T: trait_method> (x: T) {
x.method();
}
I would like this method to work also for a trait object &trait_method, otherwise I have to define another function with the same code (but a different profile):
fn f (x: &trait_method) {
x.method();
}
Why can't rust be clever and call the static or dynamic version depending if he knows the type at compile time or not (for trait objects) ?
Thanks