Closed
Description
trait Bar<T> { fn dummy(&self); }
trait Car<T> { fn dummy(&self); }
trait Foo {
type A;
type B: Bar<Self::A>;
type C: Car<Self::A>;
fn get_b(&self) -> &Self::B;
}
fn test_bar<A, B: Bar<A>>(_: &B) {}
fn test<A, F: Foo<A=A>>(f: &F) {
test_bar(f.get_b());
}
Gives me:
<anon>:15:16: 15:23 error: the trait `Bar<A>` is not implemented for the type `<F as Foo>::B` [E0277]
<anon>:15 test_bar(f.get_b());
^~~~~~~
<anon>:15:16: 15:23 error: the trait `Car<A>` is not implemented for the type `<F as Foo>::C` [E0277]
<anon>:15 test_bar(f.get_b());
^~~~~~~
error: aborting due to 2 previous errors
playpen: application terminated with error code 101
There is a workaround:
fn test<A, B: Bar<A>, C: Car<A>, F: Foo<A=A, B=B, C=C>>(f: &F) {
test_bar(f.get_b());
}
But it's ugly and should not be necessary.
We hit this problem a lot with gfx::Device, and I'd like to see cleaner use of it without explicit CommandBuffer
bounds that we use as a workaround.