I\'m trying to update some older code I wrote that basically looks like:
trait Foo{}
struct Bar>{
b: B
}
It seems that what you want is the following: for any type A, B must implement Foo. That suggests that you rely on functionality of Foo that does not depend on the value of A, which means that you can change Foo to have an associated type rather than a type parameter.
trait Foo { }
will become
trait Foo {
type T;
}
Then you can remove the A type parameter everywhere and require just B: Foo.
To elaborate on PhantomData, it has nothing to do with unsafe code, it is used to determine variance of a type parameter when the compiler cannot infer it. See RFC 738 for more information on variance and PhantomData.