typic-derive

Crates.iotypic-derive
lib.rstypic-derive
version0.3.0
sourcesrc
created_at2019-12-28 20:12:56.009938
updated_at2020-06-30 21:22:45.395538
descriptionType-safe transmutations between layout-compatible types.
homepage
repositoryhttps://github.com/jswrenn/typic
max_upload_size
id193031
size9,830
Jack Wrenn (jswrenn)

documentation

README

Typic

Typic helps you transmute fearlessly. It worries about the subtleties of soundness and safety so you don't have to!

Documentation Crates.io

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!

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Commit count: 87

cargo fmt