<Into>-like trait can't infer types even with result type

For the second problem,

impl<F, A, B> IntoSystem<(A, B)> for F
where
    for<'a> A: Fetch<'a> + 'a,
    for<'a> B: Fetch<'a> + 'a,
    for<'a> F: Fn(<A as Fetch<'a>>::Output, <B as Fetch<'a>>::Output) -> () + 'static,

Type parameters like A have to resolve into a concrete type, not one with a free lifetime parameter like Ref<'_, u32>. And indeed this:

impl<'a> Fetch<'a> for Ref<'a, u32> {

Means there is no 'x for which this bound holds:

Ref<'x, u32>: for<'a> Fetch<'a> + 'a

Being generic over borrowing or owned input types often breaks inference. Sometimes you can restore inference by being less generic in your implementations. Perhaps you can find some inspiration here.

1 Like