If I try to make a vector of function pointers, the compiler always complains about wrong types (although I don't declare any type explicitly):
fn abc() {}
fn def() {}
fn main()
{
let a = vec![abc, def];
}
error[E0308]: mismatched types
--> src/main.rs:5:13
|
5 | let a = vec![abc, def];
| ^^^^^^^^^^^^^^ expected slice, found array of 2 elements
|
= note: expected struct `Box<[fn() {abc}], _>`
found struct `Box<[fn(); 2], std::alloc::Global>`
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
error: could not compile `tes`
To learn more, run the command again with --verbose.