1 // run-pass 2 // Test that we can use method notation to call methods based on a 3 // where clause type, and not only type parameters. 4 5 6 trait Foo { foo(&self) -> i327 fn foo(&self) -> i32; 8 } 9 10 impl Foo for Option<i32> 11 { foo(&self) -> i3212 fn foo(&self) -> i32 { 13 self.unwrap_or(22) 14 } 15 } 16 17 impl Foo for Option<u32> 18 { foo(&self) -> i3219 fn foo(&self) -> i32 { 20 self.unwrap_or(22) as i32 21 } 22 } 23 check<T>(x: Option<T>) -> (i32, i32) where Option<T> : Foo24fn check<T>(x: Option<T>) -> (i32, i32) 25 where Option<T> : Foo 26 { 27 let y: Option<T> = None; 28 (x.foo(), y.foo()) 29 } 30 main()31fn main() { 32 assert_eq!(check(Some(23u32)), (23, 22)); 33 assert_eq!(check(Some(23)), (23, 22)); 34 } 35