rust/tests/run-pass-valgrind/dst-dtor-2.rs

22 lines
340 B
Rust
Raw Normal View History

static mut DROP_RAN: isize = 0;
2014-08-06 04:59:40 -05:00
struct Foo;
impl Drop for Foo {
fn drop(&mut self) {
unsafe { DROP_RAN += 1; }
}
}
2015-01-05 15:16:49 -06:00
struct Fat<T: ?Sized> {
2014-08-06 04:59:40 -05:00
f: T
}
pub fn main() {
{
let _x: Box<Fat<[Foo]>> = Box::<Fat<[Foo; 3]>>::new(Fat { f: [Foo, Foo, Foo] });
2014-08-06 04:59:40 -05:00
}
unsafe {
assert_eq!(DROP_RAN, 3);
2014-08-06 04:59:40 -05:00
}
}