1 // run-pass 2 // Test for using an object with an associated type binding as the 3 // instantiation for a generic type with a bound. 4 5 6 trait SomeTrait { 7 type SomeType; 8 get(&self) -> Self::SomeType9 fn get(&self) -> Self::SomeType; 10 } 11 get_int<T:SomeTrait<SomeType=i32>+?Sized>(x: &T) -> i3212fn get_int<T:SomeTrait<SomeType=i32>+?Sized>(x: &T) -> i32 { 13 x.get() 14 } 15 16 impl SomeTrait for i32 { 17 type SomeType = i32; get(&self) -> i3218 fn get(&self) -> i32 { 19 *self 20 } 21 } 22 main()23fn main() { 24 let x = 22; 25 let x1: &dyn SomeTrait<SomeType=i32> = &x; 26 let y = get_int(x1); 27 assert_eq!(x, y); 28 } 29