Would it ever be possible to write an HRTB for a type whose lifetime variables' names' you don't know? That is, something like
for<any lifetimes included in T> fn(T) -> u32?
I'm the author of Mockall, a popular mocking library. In order to mock generic methods, Mockall needs to store a completion function as a
Box<Any>, and later downcast it to a concrete form. Mockall does not need to downcast the method's generic types; just a
Fn object that accepts or returns those types. There is no reason why the completion function can't be
'static; Mockall already handles functions with reference arguments by adding an appropriate HRTB. The problem is that for non-static types more complicated than a reference, Mockall doesn't know what the lifetime arguments are.
One solution would be to allow
TypeId for non-
'static types. But that dead horse has been beaten enough. My request is simpler. Would it be possible to define an HRTB for every lifetime contained in a given type?