2016-11-04 10:38:04 -05:00
|
|
|
trait Foo {}
|
|
|
|
|
|
|
|
struct Bar;
|
|
|
|
|
|
|
|
static mut DROP_CALLED: bool = false;
|
|
|
|
|
|
|
|
impl Drop for Bar {
|
|
|
|
fn drop(&mut self) {
|
|
|
|
unsafe { DROP_CALLED = true; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Foo for Bar {}
|
|
|
|
|
|
|
|
fn main() {
|
2019-05-30 03:58:30 -05:00
|
|
|
let b: Box<dyn Foo> = Box::new(Bar);
|
2016-11-04 10:38:04 -05:00
|
|
|
assert!(unsafe { !DROP_CALLED });
|
|
|
|
drop(b);
|
|
|
|
assert!(unsafe { DROP_CALLED });
|
|
|
|
}
|