rust/tests/run-pass/call_drop_on_array_elements.rs
2016-11-04 17:34:33 +01:00

17 lines
283 B
Rust

struct Bar;
static mut DROP_COUNT: usize = 0;
impl Drop for Bar {
fn drop(&mut self) {
unsafe { DROP_COUNT += 1; }
}
}
fn main() {
let b = [Bar, Bar, Bar, Bar];
assert_eq!(unsafe { DROP_COUNT }, 0);
drop(b);
assert_eq!(unsafe { DROP_COUNT }, 4);
}