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