trait Foo { fn get() -> T; } struct S { x: int } impl S : Foo { fn get() -> int { self.x } } fn main() { let x = @S { x: 1 }; let y = x as @Foo; assert y.get() == 1; }