2018-08-30 14:18:55 +02:00
|
|
|
// run-pass
|
2018-08-31 15:02:01 +02:00
|
|
|
#![allow(non_camel_case_types)]
|
2015-03-22 13:13:15 -07:00
|
|
|
|
2012-08-28 19:49:36 -07:00
|
|
|
trait bar<T> {
|
2013-03-12 19:32:14 -07:00
|
|
|
fn get_bar(&self) -> T;
|
2012-08-28 19:49:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
fn foo<T, U: bar<T>>(b: U) -> T {
|
|
|
|
b.get_bar()
|
|
|
|
}
|
|
|
|
|
2012-09-07 19:04:40 -07:00
|
|
|
struct cbar {
|
2015-03-25 17:06:52 -07:00
|
|
|
x: isize,
|
2012-09-07 19:04:40 -07:00
|
|
|
}
|
|
|
|
|
2015-03-25 17:06:52 -07:00
|
|
|
impl bar<isize> for cbar {
|
|
|
|
fn get_bar(&self) -> isize {
|
2012-08-28 19:49:36 -07:00
|
|
|
self.x
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-25 17:06:52 -07:00
|
|
|
fn cbar(x: isize) -> cbar {
|
2012-09-05 15:58:43 -07:00
|
|
|
cbar {
|
|
|
|
x: x
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2015-03-25 17:06:52 -07:00
|
|
|
let x: isize = foo::<isize, cbar>(cbar(5));
|
2013-05-18 22:02:45 -04:00
|
|
|
assert_eq!(x, 5);
|
2012-08-28 19:49:36 -07:00
|
|
|
}
|