I'm dealing with an issue where the compiler is unable to infer a type: Rust Playground
Essentially, I'm looking for a way I can amend this to get the compiler to infer the type itself without any help. The constraint that is really here is that
StateParam::Output is essentially
Self except that I can't really do that because of lifetime differences.
I believe that the issue is that the compiler doesn't treat the type of the argument to a closure as a single unique type. It could be that it implements the
Fn traits for several possible input types. Therefore, it cannot deduce what
A should be. Here's another option that compiles:
let state = IntoState::<(Param2<Param1<'_>>,)>::into_state(func);
However, I don't think there's any easy fix to this.
Is the constraint that
StateParam::Output = Self modulo lifetimes not sufficient for the compiler to deduce that it's a unique type? I'm not sure how to express that constraint though.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.