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) {
|
|
|
|
unsafe { DROP_CALLED = true; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 });
|
|
|
|
}
|