rust/tests/run-pass/call_drop_on_fat_ptr_array_elements.rs

21 lines
373 B
Rust
Raw Normal View History

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) {
unsafe { DROP_COUNT += 1; }
}
}
fn main() {
let b: [Box<Foo>; 4] = [Box::new(Bar), Box::new(Bar), Box::new(Bar), Box::new(Bar)];
assert_eq!(unsafe { DROP_COUNT }, 0);
drop(b);
assert_eq!(unsafe { DROP_COUNT }, 4);
}