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