mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
26 lines
324 B
Rust
26 lines
324 B
Rust
trait Foo {
|
|
fn f(&self);
|
|
}
|
|
|
|
struct Bar {
|
|
x: isize,
|
|
}
|
|
|
|
impl Drop for Bar {
|
|
fn drop(&mut self) {}
|
|
}
|
|
|
|
impl Foo for Bar {
|
|
fn f(&self) {
|
|
println!("hi");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
let x = Box::new(Bar { x: 10 });
|
|
let y: Box<dyn Foo> = x as Box<dyn Foo>;
|
|
let _z = y.clone(); //~ ERROR the method
|
|
}
|