What is the difference generics and inline (I don't know what they are called) type definitions?
Example code:
fn main() {
c(|| {
println!("hello");
})
}
fn a<F>(f: F)
where
F: FnOnce() + Send + 'static,
{
f();
}
fn b<F: FnOnce() + Send + 'static>(f: F) {
f();
}
fn c(f: FnOnce() + Send + 'static) {
f();
}
Here a and b works fine but c gives an error:
"trait objects must include the dyn keyword"
If I add the dyn keyword this time it gives another error: "the size for values of type (dyn FnOnce() + Send + 'static) cannot be known at compilation time"
So can you explain me how the type declaration in c is different?