Neither of these are able to resolve foo.
trait A { }
impl A {
fn foo() -> int { 10 }
}
impl int: A { }
fn main() {
let x = &0;
let y = x as &A;
y.foo();
}
trait A { }
impl A {
fn foo() -> int { 10 }
}
impl int: A { }
fn f<T: A>(x: &T) {
assert x.foo() == 10;
}
fn main() { }
This pattern is makes semantic sense, though it is odd and possibly useless.