2017-06-01 19:24:21 -05:00
|
|
|
struct 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;
|
|
|
|
}
|
2017-06-01 19:24:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let b = [Bar, Bar, Bar, Bar];
|
|
|
|
assert_eq!(unsafe { DROP_COUNT }, 0);
|
|
|
|
drop(b);
|
|
|
|
assert_eq!(unsafe { DROP_COUNT }, 4);
|
|
|
|
|
|
|
|
// check empty case
|
2022-06-20 17:30:34 -05:00
|
|
|
let b: [Bar; 0] = [];
|
2017-06-01 19:24:21 -05:00
|
|
|
drop(b);
|
|
|
|
assert_eq!(unsafe { DROP_COUNT }, 4);
|
|
|
|
}
|