I want to pass a function factory, i.e. a higher order function, but I get call expression requires function errors.
// function that takes 4 f32 generates a function which maps one f32 to another f32
// DOESN'T WORK
type FunctionFactoryType = Box<dyn Fn(f32, f32, f32, f32) -> (dyn Fn(f32) -> f32)>;
fn abc(x: FunctionFactoryType) {
(*x)(1.0, 2.0, 3.0, 4.0);
// ^ call expression requires function
// expected function, found `(dyn Fn(f32, f32, f32, f32) -> (dyn Fn(f32) -> f32 + 'static) + 'static)`
}
If I use a "regular function" (not higher order), i.e. Box<dyn Fn(f32 -> f32)> it works. Am I missing something or is this a Rust error?