1 // run-pass
2 trait Factory {
3     type Product;
create(&self) -> <Self as Factory>::Product4     fn create(&self) -> <Self as Factory>::Product;
5 }
6 
7 impl Factory for f64 {
8     type Product = f64;
create(&self) -> f649     fn create(&self) -> f64 { *self * *self }
10 }
11 
12 impl<A: Factory, B: Factory> Factory for (A, B) {
13     type Product = (<A as Factory>::Product, <B as Factory>::Product);
create(&self) -> (<A as Factory>::Product, <B as Factory>::Product)14     fn create(&self) -> (<A as Factory>::Product, <B as Factory>::Product) {
15         let (ref a, ref b) = *self;
16         (a.create(), b.create())
17     }
18 }
19 
main()20 fn main() {
21     assert_eq!((16., 25.), (4., 5.).create());
22 }
23