Crates.io | typic-derive |
lib.rs | typic-derive |
version | 0.3.0 |
source | src |
created_at | 2019-12-28 20:12:56.009938 |
updated_at | 2020-06-30 21:22:45.395538 |
description | Type-safe transmutations between layout-compatible types. |
homepage | |
repository | https://github.com/jswrenn/typic |
max_upload_size | |
id | 193031 |
size | 9,830 |
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!