]>
Commit | Line | Data |
---|---|---|
223e47cc LB |
1 | // Copyright 2012 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 XL |
11 | // run-pass |
12 | #![allow(non_camel_case_types)] | |
c34b1796 | 13 | |
223e47cc LB |
14 | trait bar<T> { |
15 | fn get_bar(&self) -> T; | |
16 | } | |
17 | ||
18 | fn foo<T, U: bar<T>>(b: U) -> T { | |
19 | b.get_bar() | |
20 | } | |
21 | ||
22 | struct cbar { | |
c34b1796 | 23 | x: isize, |
223e47cc LB |
24 | } |
25 | ||
c34b1796 AL |
26 | impl bar<isize> for cbar { |
27 | fn get_bar(&self) -> isize { | |
223e47cc LB |
28 | self.x |
29 | } | |
30 | } | |
31 | ||
c34b1796 | 32 | fn cbar(x: isize) -> cbar { |
223e47cc LB |
33 | cbar { |
34 | x: x | |
35 | } | |
36 | } | |
37 | ||
38 | pub fn main() { | |
c34b1796 | 39 | let x: isize = foo::<isize, cbar>(cbar(5)); |
970d7e83 | 40 | assert_eq!(x, 5); |
223e47cc | 41 | } |