Struct with generic function parameter

pub struct Messy<Fiii: fn (lhs: i32, rhs: i32) -> i32> {
data: std::marker::PhantomData<Fiii>
}

does not compile

I am clearly doing something stupid. How do I fix this?

You can't specify argument names in function types. Additionally, the lower case version is a function pointer, which is not a trait, so you would need the upper case version instead.

pub struct Messy<Fiii: Fn(i32, i32) -> i32> {
    data: std::marker::PhantomData<Fiii>
}
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.