2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2015-01-08 01:25:56 +00:00
|
|
|
#![feature(box_syntax)]
|
2014-05-06 01:56:44 +00:00
|
|
|
|
2012-11-29 18:59:49 +00:00
|
|
|
trait Foo {
|
2014-07-08 06:19:35 +00:00
|
|
|
fn f(self: Box<Self>);
|
2012-11-29 18:59:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct S {
|
2015-03-26 00:06:52 +00:00
|
|
|
x: isize
|
2012-11-29 18:59:49 +00:00
|
|
|
}
|
|
|
|
|
2013-02-14 19:47:00 +00:00
|
|
|
impl Foo for S {
|
2014-07-08 06:19:35 +00:00
|
|
|
fn f(self: Box<S>) {
|
2013-05-19 02:02:45 +00:00
|
|
|
assert_eq!(self.x, 3);
|
2012-11-29 18:59:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-02 03:43:17 +00:00
|
|
|
pub fn main() {
|
2014-05-06 01:56:44 +00:00
|
|
|
let x = box S { x: 3 };
|
|
|
|
let y = x as Box<Foo>;
|
2012-11-29 18:59:49 +00:00
|
|
|
y.f();
|
|
|
|
}
|