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