2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2014-05-05 20:56:44 -05:00
|
|
|
|
2012-11-29 13:18:36 -06:00
|
|
|
trait Foo<T> {
|
2013-03-12 21:32:14 -05:00
|
|
|
fn get(&self) -> T;
|
2012-11-29 13:18:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
struct S {
|
2015-03-25 19:06:52 -05:00
|
|
|
x: isize
|
2012-11-29 13:18:36 -06:00
|
|
|
}
|
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
impl Foo<isize> for S {
|
|
|
|
fn get(&self) -> isize {
|
2012-11-29 13:18:36 -06:00
|
|
|
self.x
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-01 21:43:17 -06:00
|
|
|
pub fn main() {
|
2021-08-24 19:39:40 -05:00
|
|
|
let x = Box::new(S { x: 1 });
|
2019-05-28 13:47:21 -05:00
|
|
|
let y = x as Box<dyn Foo<isize>>;
|
2013-05-18 21:02:45 -05:00
|
|
|
assert_eq!(y.get(), 1);
|
2012-11-29 13:18:36 -06:00
|
|
|
}
|