The things are going relatively OK when it's tried for Fn traits. But I'd prefer to have one for static fns in my case as it will allow to provide trait implementation for other signatures and have custom trait implementations at once.
for<'a, 'b> fn(&'a u8, &'b u16) -> Fut is not the same type as for<'a, 'b> fn(&'a u8, &'b u16) -> Fut {lol}. The former is a function pointer, while the second refers to the specific function lol. You can try to use check(lol as fn(_, _) -> _).
Meh... I haven't noticed that each static function with identical signature represents a different type
So, the thing I wanted is impossible in current Rust's type system.
I cannot use as fn as the signature itself is quite insane.
So, the only option is to go with Fn trait and have wrapper types. The last thing that bothers me is using #![feature(unboxed_closures)]. However, compiler doesn't allow to get rid of it.
I've ended up with the situation that I cannot pass static async fn anywhere at all:
The only thing that works is to expose argument lifetimes as lifetime parameters. However that's not practical at all as doesn't allow me to call the actual function in a meaningful context. For such wrapping being useful there should be HRTB used (which is implicitly true if arguments are not restricted with any explicit lifetime parameters). However, using HRTB just doesn't allow to accept async fn pointers and I cannot figure out how to make it work.
Wow, how obscure could a half page of code be? Having been programming for decades the only thing I recognize there is "fn", "u8", "u16" and "Result". Cannot begin to fathom what the rest of it is even hinting at.
Is this how regular Rust code will look in the async world?
However, as I see, now "the problem" is shifted slightly to another place. The point is to accept arbitrary async fn with a given signature. So, I still have to have something generic, which accepts arbitrary async fn and converts it into one returning Boxed Future. Any ideas?