2012-10-31 22:09:26 +00:00
|
|
|
trait Foo {
|
2013-02-08 03:33:12 +00:00
|
|
|
fn f(&self);
|
2012-10-31 22:09:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Bar {
|
2015-01-08 10:54:35 +00:00
|
|
|
x: isize,
|
2012-11-14 06:22:37 +00:00
|
|
|
}
|
|
|
|
|
2013-02-14 19:47:00 +00:00
|
|
|
impl Drop for Bar {
|
2013-09-17 01:18:07 +00:00
|
|
|
fn drop(&mut self) {}
|
2012-10-31 22:09:26 +00:00
|
|
|
}
|
|
|
|
|
2013-02-14 19:47:00 +00:00
|
|
|
impl Foo for Bar {
|
2013-02-08 03:33:12 +00:00
|
|
|
fn f(&self) {
|
2014-01-09 10:06:55 +00:00
|
|
|
println!("hi");
|
2012-10-31 22:09:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-25 00:39:40 +00:00
|
|
|
|
|
|
|
|
2012-10-31 22:09:26 +00:00
|
|
|
fn main() {
|
2021-08-25 00:39:40 +00:00
|
|
|
let x = Box::new(Bar { x: 10 });
|
2019-05-28 18:46:13 +00:00
|
|
|
let y: Box<dyn Foo> = x as Box<dyn Foo>;
|
2020-09-26 21:20:14 +00:00
|
|
|
let _z = y.clone(); //~ ERROR the method
|
2012-10-31 22:09:26 +00:00
|
|
|
}
|