1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
// run-pass mod a { pub trait Foo { fn foo() -> Self; } impl Foo for isize { fn foo() -> isize { 3 } } impl Foo for usize { fn foo() -> usize { 5 } } } pub fn main() { let x: isize = a::Foo::foo(); let y: usize = a::Foo::foo(); assert_eq!(x, 3); assert_eq!(y, 5); }