So… my scheme for foreign traits doesn’t seem to work.
With local traits, I implement them in the following way:
impl<Proxy: delegate_LocalTrait> LocalTrait for Proxy {
/* generated implementation */
}
Which is fine since delegate_LocalTrait (generated by my macro) and LocalTrait are local.
But with a foreign trait this becomes:
impl<Proxy: delegate_ForeignTrait> ForeignTrait for Proxy {
/* generated implementation */
}
And this is where the orphan rules kick in: I would need to use Proxy as a type parameter for some local type, which is not what I want (or else I’ll have to use an intermediate struct on which the trait will be implemented).
Moreover, even without the orphan rules (I find it strange that they would apply since my generic parameter is constrained by delegate_ForeignTrait, which is a local trait), it doesn’t work for traits that already have “automatic implementation” (such as Into being implemented from From).
Implementation for foreign traits looks difficult.