2015-01-07 18:53:58 -08:00
|
|
|
#![feature(box_syntax)]
|
2014-05-05 18:56:44 -07:00
|
|
|
|
2012-10-31 15:09:26 -07:00
|
|
|
trait Foo {
|
2013-02-07 19:33:12 -08:00
|
|
|
fn f(&self);
|
2012-10-31 15:09:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Bar {
|
2015-01-08 21:54:35 +11:00
|
|
|
x: isize,
|
2012-11-14 01:22:37 -05:00
|
|
|
}
|
|
|
|
|
2013-02-14 11:47:00 -08:00
|
|
|
impl Drop for Bar {
|
2013-09-16 21:18:07 -04:00
|
|
|
fn drop(&mut self) {}
|
2012-10-31 15:09:26 -07:00
|
|
|
}
|
|
|
|
|
2013-02-14 11:47:00 -08:00
|
|
|
impl Foo for Bar {
|
2013-02-07 19:33:12 -08:00
|
|
|
fn f(&self) {
|
2014-01-09 21:06:55 +11:00
|
|
|
println!("hi");
|
2012-10-31 15:09:26 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2014-05-05 18:56:44 -07:00
|
|
|
let x = box Bar { x: 10 };
|
2019-05-28 14:46:13 -04:00
|
|
|
let y: Box<dyn Foo> = x as Box<dyn Foo>;
|
2015-05-02 23:30:59 -06:00
|
|
|
let _z = y.clone(); //~ ERROR no method named `clone` found
|
2012-10-31 15:09:26 -07:00
|
|
|
}
|