I want to work with FnMut(&[f32]) -> f32, so as not to copy / paste the full signature, I want to enter 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
Then I tried:
trait Boo: FnMut(&[f32]) -> f32 {}
fn f<F: Boo>(mut f: F) {}
it compiled, but if I try to use Booinstead of the property elsewhere:
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 a way to create a specific alias FnMutthat I can use instead FnMut(&[f32]) -> f32?
source
share