I want to work with FnMut(&[f32]) -> f32,
to not copy/paste full signature, I want to introduce some kind of alias, but
type Boo = FnMut(&[f32]) -> f32;
fn f<F: Boo>(mut f: F) {}
Causes a compiler error:
error[E0404]: expected trait, found type alias `Boo`
--> src/main.rs:3:13
|
3 | fn f<F: Boo>(mut f: F) {}
| ^^^ type aliases cannot be used for traits
I then tried:
trait Boo: FnMut(&[f32]) -> f32 {}
fn f<F: Boo>(mut f: F) {}
it compiled, but if I try to use Boo in place of trait in another place:
trait Boo: FnMut(&[f32]) -> f32 {}
struct X(Vec<Box<Boo>>);
I get:
error[E0191]: the value of the associated type `Output` (from the trait `std::ops::FnOnce`) must be specified
--> src/main.rs:3:18
|
3 | struct X(Vec<Box<Boo>>);
| ^^^ missing associated type `Output` value
Is there any way to create an alias of a specific FnMut which I can use
instead of FnMut(&[f32]) -> f32?