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