]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/traits/trait-bounds.rs
New upstream version 1.31.0~beta.4+dfsg1
[rustc.git] / src / test / run-pass / traits / trait-bounds.rs
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
11 // run-pass
12 #![allow(dead_code)]
13 #![allow(non_camel_case_types)]
14 #![allow(non_snake_case)]
15
16 trait connection {
17 fn read(&self) -> isize;
18 }
19
20 trait connection_factory<C:connection> {
21 fn create(&self) -> C;
22 }
23
24 type my_connection = ();
25 type my_connection_factory = ();
26
27 impl connection for () {
28 fn read(&self) -> isize { 43 }
29 }
30
31 impl connection_factory<my_connection> for my_connection_factory {
32 fn create(&self) -> my_connection { () }
33 }
34
35 pub fn main() {
36 let factory = ();
37 let connection = factory.create();
38 let result = connection.read();
39 assert_eq!(result, 43);
40 }