]> git.proxmox.com Git - rustc.git/blame - src/test/ui/run-pass/issues/issue-18655.rs
New upstream version 1.30.0+dfsg1
[rustc.git] / src / test / ui / run-pass / issues / issue-18655.rs
CommitLineData
62682a34
SL
1// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
b7449926 11// run-pass
62682a34
SL
12trait Factory {
13 type Product;
14 fn create(&self) -> <Self as Factory>::Product;
15}
16
17impl Factory for f64 {
18 type Product = f64;
19 fn create(&self) -> f64 { *self * *self }
20}
21
22impl<A: Factory, B: Factory> Factory for (A, B) {
23 type Product = (<A as Factory>::Product, <B as Factory>::Product);
24 fn create(&self) -> (<A as Factory>::Product, <B as Factory>::Product) {
25 let (ref a, ref b) = *self;
26 (a.create(), b.create())
27 }
28}
29
30fn main() {
31 assert_eq!((16., 25.), (4., 5.).create());
32}