]>
Commit | Line | Data |
---|---|---|
b7449926 | 1 | // run-pass |
62682a34 SL |
2 | trait Factory { |
3 | type Product; | |
4 | fn create(&self) -> <Self as Factory>::Product; | |
5 | } | |
6 | ||
7 | impl Factory for f64 { | |
8 | type Product = f64; | |
9 | 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); | |
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 | ||
20 | fn main() { | |
21 | assert_eq!((16., 25.), (4., 5.).create()); | |
22 | } |