| Crates.io | typic |
| lib.rs | typic |
| version | 0.3.0 |
| created_at | 2019-12-28 20:21:34.229435+00 |
| updated_at | 2020-06-30 21:25:03.845252+00 |
| description | Type-safe transmutations between layout-compatible types. |
| homepage | |
| repository | https://github.com/jswrenn/typic |
| max_upload_size | |
| id | 193032 |
| size | 94,655 |
Typic helps you transmute fearlessly. It worries about the subtleties of soundness and safety so you don't have to!
Just import it and replace your #[repr(...)] attributes with #[typic::repr(...)]:
// Import it!
use typic::{self, TransmuteInto};
// Update your attributes!
#[typic::repr(C)]
pub struct Foo(pub u8, pub u16);
// Transmute fearlessly!
let _ : Foo = u32::default().transmute_into(); // Alchemy achieved!
let _ : u32 = Foo::default().transmute_into(); // Compiler Error!