Some libraries such as Bevy or Actix Web have functions which accept user defined functions with any amount of parameters.
Examples:
Actix Web:
async fn fn1(path: web::Path<String>) -> impl Responder {
// not important
}
async fn fn2(_req: HttpRequest) -> impl Responder {
// not important
}
let app = App::new()
.route("/", web::get().to(fn2))
.route("/{name}", web::get().to(fn1));
Bevy:
fn fn1(mut commands: Commands) {}
fn fn2(mut commands: Commands, time: Res<Time>) {}
App::new().add_system(fn1).add_system(fn2);
As you can see in both cases the functions web::get().to(), add_system() accept functions with dynamic number and types of parameters as their parameter. They're not macros. How can I achieve this? Is there a name for this? Thanks