2016-11-04 11:34:33 -05:00
|
|
|
trait Foo {}
|
|
|
|
|
|
|
|
struct Bar;
|
|
|
|
|
|
|
|
impl Foo for Bar {}
|
|
|
|
|
|
|
|
static mut DROP_COUNT: usize = 0;
|
|
|
|
|
|
|
|
impl Drop for Bar {
|
|
|
|
fn drop(&mut self) {
|
2022-06-20 17:30:34 -05:00
|
|
|
unsafe {
|
|
|
|
DROP_COUNT += 1;
|
|
|
|
}
|
2016-11-04 11:34:33 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2019-05-30 03:58:30 -05:00
|
|
|
let b: [Box<dyn Foo>; 4] = [Box::new(Bar), Box::new(Bar), Box::new(Bar), Box::new(Bar)];
|
2016-11-04 11:34:33 -05:00
|
|
|
assert_eq!(unsafe { DROP_COUNT }, 0);
|
|
|
|
drop(b);
|
|
|
|
assert_eq!(unsafe { DROP_COUNT }, 4);
|
|
|
|
}
|