2018-08-30 14:18:55 +02:00
|
|
|
// run-pass
|
2015-01-08 02:25:56 +01:00
|
|
|
#![feature(box_syntax)]
|
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() {
|
2014-05-05 18:56:44 -07:00
|
|
|
let x = box S { x: 1 };
|
2015-03-25 17:06:52 -07:00
|
|
|
let y = x as Box<Foo<isize>>;
|
2013-05-18 22:02:45 -04:00
|
|
|
assert_eq!(y.get(), 1);
|
2012-11-29 11:18:36 -08:00
|
|
|
}
|