If functions are addressable as a type to query their <... as FnOnce>::Output
, it would make sense to take a $:ty
match.
However, this isn't possible even with $($:tt)+
matches and unboxed_closures
in user code:
error[E0575]: expected associated type, found method `MyTrait::foo`
--> src/main.rs:13:23
|
13 | let _ : OutputOf!(<MyStruct<u32> as MyTrait<u32>>::foo)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a associated type
I'd like to note though that if we get <..>
elision for generic arguments, OutputOf!
can almost be implemented purely in library code:
macro_rules! OutputOf {
($($path:tt)+) => (<$($path)+ as FnOnce<..>>::Output);
}
Of course, if it becomes a compiler built-in macro to work around the unstable nature of the Fn*
traits, then you could handwave a bit and say it takes a "path to a method" (which seems the compiler already knows about, to say that it isn't an associated type).
Sorry, I didn't see that you mentioned type directly. I'm too tired to reorganize this on my phone but the last paragraph is still directly relevant, it just needs the earlier bits for context.
I've also mixed up what works and what doesn't a bit at this point so I may have missed something obvious, that's why I'm leaning on actually putting things on play.