fn dyn_dispatch(t: &dyn F) {
t.f();
}
fn dyn_dispatch1<T: F + ?Sized>(t: &T) {
t.f();
}
the difference is that the first one is a single function that can take in input an object that has a function table with all the functions of the trait while the second one is a template for the compiler to generate a specific function for the type you are using it with
1 Like
The first function uses dynamic dispatching, while the second uses static dispatching.
1 Like