rust/src/test/run-pass/unique-object.rs

23 lines
228 B
Rust
Raw Normal View History

2012-10-31 17:09:26 -05:00
trait Foo {
fn f();
}
struct Bar {
x: int
}
impl Bar : Foo {
fn f() {
io::println("hi");
}
}
fn main() {
let x = ~Bar { x: 10 };
let y = x as ~Foo;
let z = copy y;
y.f();
z.f();
}