typic 0.3.0

Type-safe transmutations between layout-compatible types.
Documentation

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, transmute::StableTransmuteInto, stability::StableABI};

// Update your attributes!
#[typic::repr(C)]
#[derive(StableABI)]
pub struct Foo(pub u8, pub u16);

// Transmute fearlessly!
let _ : Foo = 64u32.transmute_into(); // Alchemy achieved!
# use typic::{self, TransmuteInto};
# #[typic::repr(C)]
# #[derive(StableABI)]
# struct Foo(pub u8, pub u16);
let _ : u32 = Foo(16, 12).transmute_into(); // Compile Error!