Crate typic

Source
Expand description

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!
let _ : u32 = Foo(16, 12).transmute_into(); // Compile Error!

Modules§

extras
Examples demonstrating typic’s ability to express common abstractions.
layout
Details about the layout of types.
stability
Traits for communicating layout guarantees.
transmute
Traits for safe and sound transmutation.

Attribute Macros§

repr
Use #[typic::repr(...)] instead of #[repr(...)] on your type definitions.