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