]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/mid-path-type-params.rs
85c05d408e8ab4a9a9d3473cdc0fe411ca06ca9b
[rust.git] / src / test / run-pass / mid-path-type-params.rs
1 // Copyright 2014 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
11 struct S<T> {
12     contents: T,
13 }
14
15 impl<T> S<T> {
16     fn new<U>(x: T, _: U) -> S<T> {
17         S {
18             contents: x,
19         }
20     }
21 }
22
23 trait Trait<T> {
24     fn new<U>(x: T, y: U) -> Self;
25 }
26
27 struct S2 {
28     contents: int,
29 }
30
31 impl Trait<int> for S2 {
32     fn new<U>(x: int, _: U) -> S2 {
33         S2 {
34             contents: x,
35         }
36     }
37 }
38
39 pub fn main() {
40     let _ = S::<int>::new::<f64>(1, 1.0);
41     let _: S2 = Trait::<int>::new::<f64>(1, 1.0);
42 }