2024-02-16 20:02:50 +00:00
|
|
|
//@ run-pass
|
2018-09-25 23:51:35 +02:00
|
|
|
#![allow(dead_code)]
|
2018-08-31 15:02:01 +02:00
|
|
|
#![allow(non_camel_case_types)]
|
|
|
|
|
#![allow(non_snake_case)]
|
2015-03-22 13:13:15 -07:00
|
|
|
|
2012-07-12 18:04:40 -07:00
|
|
|
trait connection {
|
2015-03-25 17:06:52 -07:00
|
|
|
fn read(&self) -> isize;
|
2012-07-12 18:04:40 -07:00
|
|
|
}
|
|
|
|
|
|
2013-02-20 17:07:17 -08:00
|
|
|
trait connection_factory<C:connection> {
|
2013-03-12 19:32:14 -07:00
|
|
|
fn create(&self) -> C;
|
2012-07-12 18:04:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type my_connection = ();
|
|
|
|
|
type my_connection_factory = ();
|
|
|
|
|
|
2013-02-14 11:47:00 -08:00
|
|
|
impl connection for () {
|
2015-03-25 17:06:52 -07:00
|
|
|
fn read(&self) -> isize { 43 }
|
2012-07-12 18:04:40 -07:00
|
|
|
}
|
|
|
|
|
|
2013-02-14 11:47:00 -08:00
|
|
|
impl connection_factory<my_connection> for my_connection_factory {
|
2013-03-12 19:32:14 -07:00
|
|
|
fn create(&self) -> my_connection { () }
|
2012-07-12 18:04:40 -07:00
|
|
|
}
|
|
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2012-07-12 18:04:40 -07:00
|
|
|
let factory = ();
|
2023-06-12 16:55:36 +08:00
|
|
|
let connection: () = factory.create();
|
2012-07-12 18:04:40 -07:00
|
|
|
let result = connection.read();
|
2013-05-18 22:02:45 -04:00
|
|
|
assert_eq!(result, 43);
|
2012-07-12 18:04:40 -07:00
|
|
|
}
|