Generic Closures and Higher-Ranked Trait Bounds outside of lifetimes

This was originally prompted by a question I wrote on the user forums.

What is the current state of HRTBs for traits?

I know they're not currently implemented, but are there any "creative workarounds" in the same vein as @dtolnay's Autoref-based stable specialization which would let me have a where clause along the lines of F: for<T: SomeTrait> FnMut(&mut T)?

You can use a custom trait with a method that has a <T> generic parameter and then define a macro to implement it with closure-like syntax (but where macro users will need to specify capture variables manually).

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