rust/library/core/tests/manually_drop.rs

20 lines
421 B
Rust
Raw Normal View History

2018-07-27 05:12:55 -05:00
use core::mem::ManuallyDrop;
#[test]
fn smoke() {
struct TypeWithDrop;
impl Drop for TypeWithDrop {
fn drop(&mut self) {
unreachable!("Should not get dropped");
}
}
let x = ManuallyDrop::new(TypeWithDrop);
drop(x);
2018-08-03 11:02:34 -05:00
// also test unsizing
let x: Box<ManuallyDrop<[TypeWithDrop]>> =
2018-08-06 08:52:36 -05:00
Box::new(ManuallyDrop::new([TypeWithDrop, TypeWithDrop]));
2018-08-03 11:02:34 -05:00
drop(x);
2018-07-27 05:12:55 -05:00
}