I'm trying add functions with different arguments to a vector.
fn f1() {
println!("Hello, World!");
}
fn f2(s: &str) -> String {
String::from(s)
}
fn f3(i: i32) {
println!("{}", i);
}
fn main() {
let v = vec![f1, f3, f2];
}
But this gives the error:
error[E0308]: mismatched types --> src/main.rs:12:22 | 12 | let v = vec![f1, f3, f2]; | ^^ incorrect number of function parameters | = note: expected type `fn() {f1}` found fn item `fn(i32) {f3}`
Is there any way I can make this work?