Idea: It would be nice to match traits on 'as' conversion. This currently can't be done.
Why: I was writing a small reflection lib for my app so I could load the reflection data from a separate dynamic lib and then enumerate the methods / types into the main application.
I was building most this with a proc_macro but was thinking i could just use type_name & a trait to greatly simplify building all the info. However, there isn't a way to match against casting to a static function and the implementation basically became near impossible with a decent interface. I also couldn't use things like transmute_copy to get pointer references since function items have a default size of 0 until cast ... which I can't do inside a trait.
Solution 1: Implement Into for all as conversions by default and people can always match 'as' with an existing trait. Advantage no real compiler changes. Downsides can't actually use the real 'as' syntax here.
Solution 2: New trait matching syntax as(T) then the 'as' syntax could be used within the trait as expected. As is essentially 'compiler magic' as implemented currently so the scope of a change like this I'd imagine is relatively low since the logic in the compiler to detect 'as' compatibility already exists.
impl<F> MyTrait for F
where F: Copy + as(fn()->())
I can work around this with a proc macro but in general having to use proc macros for something that would be otherwise simple seems really really really weird and unnecessary.