2016-11-04 11:51:13 -05:00
|
|
|
trait Foo {}
|
|
|
|
|
|
|
|
struct Bar;
|
|
|
|
|
|
|
|
static mut DROP_CALLED: bool = false;
|
|
|
|
|
|
|
|
impl Drop for Bar {
|
|
|
|
fn drop(&mut self) {
|
2022-06-20 17:30:34 -05:00
|
|
|
unsafe {
|
|
|
|
DROP_CALLED = true;
|
|
|
|
}
|
2016-11-04 11:51:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Foo for Bar {}
|
|
|
|
|
|
|
|
use std::rc::Rc;
|
|
|
|
|
|
|
|
fn main() {
|
2019-05-30 03:58:30 -05:00
|
|
|
let b: Rc<dyn Foo> = Rc::new(Bar);
|
2016-11-04 11:51:13 -05:00
|
|
|
assert!(unsafe { !DROP_CALLED });
|
|
|
|
drop(b);
|
|
|
|
assert!(unsafe { DROP_CALLED });
|
|
|
|
}
|