Hey,
I'm playing around with generics in rust, finding it hard to google my exact question sometimes ๐ค
Would anyone be to let me know if there is a way to make this compile while keeping the associated type on UtilityInput?
pub trait UtilityInput {
type Q: ReadOnlyWorldQuery;
}
impl<F: Send + Sync + 'static, T: Component> UtilityInput for F
where
F: Fn(&T) -> f32,
{
type Q = &'static T;
}
#[derive(Component)]
pub struct AI {}
fn utility_input<In: UtilityInput>(q_ai: Query<&mut AI>, q_input: Query<In::Q>) {}
The error for the impl UtilityInput
the type parameter `T` is not constrained by the impl trait, self type, or predicates
unconstrained type parameter
I want to avoid having to pass multiple generic parameters to the generic utility_input function.