mirror of
https://github.com/Lokathor/bytemuck.git
synced 2024-11-24 15:52:24 +00:00
1a4c11a675
* Use transmute! to enforce safer transmute_copy use * Test fix for #71
14 lines
306 B
Rust
14 lines
306 B
Rust
use bytemuck::TransparentWrapper;
|
|
|
|
#[repr(transparent)]
|
|
struct Wrap(Box<u32>);
|
|
|
|
// SAFETY: it's #[repr(transparent)]
|
|
unsafe impl TransparentWrapper<Box<u32>> for Wrap {}
|
|
|
|
fn main() {
|
|
let value = Box::new(5);
|
|
// This used to duplicate the wrapped value, creating a double free :(
|
|
Wrap::wrap(value);
|
|
}
|