If I have an associated type that impls some trait or is some other known type, I can't treat it as so. Example (playpen link):
trait DoNothing {
type Output;
}
struct Bob;
impl Bob {
fn print() { println!("I AM BOB!"); }
}
impl DoNothing for Bob {
type Output = Bob;
}
type BobAlso = <Bob as DoNothing>::Output;
fn main() {
// works fine:
Bob::print();
// compiler error:
BobAlso::print();
}
The type BobAlso is (or should be) just an alias for Bob, however when I try to call its print() function, the compiler complains that there is no print for <Bob as DoNothing>::Output without figuring out that that it is Bob.
If I have an associated type that impls some trait or is some other known type, I can't treat it as so. Example (playpen link):
The type
BobAlsois (or should be) just an alias forBob, however when I try to call itsprint()function, the compiler complains that there is noprintfor<Bob as DoNothing>::Outputwithout figuring out that that it isBob.