Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jswrenn/typic
Type-safe transmutations between layout-compatible types.
https://github.com/jswrenn/typic
rust safe-abstraction transmute zero-cost-abstraction
Last synced: about 1 month ago
JSON representation
Type-safe transmutations between layout-compatible types.
- Host: GitHub
- URL: https://github.com/jswrenn/typic
- Owner: jswrenn
- License: apache-2.0
- Archived: true
- Created: 2019-12-28T19:50:01.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-11T20:39:11.000Z (over 4 years ago)
- Last Synced: 2024-09-19T18:17:44.159Z (3 months ago)
- Topics: rust, safe-abstraction, transmute, zero-cost-abstraction
- Language: Rust
- Homepage: https://crates.io/crates/typic
- Size: 199 KB
- Stars: 121
- Watchers: 8
- Forks: 4
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
**ANNOUNCEMENT:** The primary purpose of Typic was to prototype zero-compromise designs for a safe transmute language feature. [Read the resulting RFC draft here](https://github.com/rust-lang/project-safe-transmute/pull/5)!
---
# Typic
Typic helps you transmute fearlessly. It worries about the subtleties of
***[soundness]*** and ***[safety]*** so you don't have to![![Documentation](https://docs.rs/typic/badge.svg)](https://docs.rs/typic/)
[![Crates.io](https://img.shields.io/crates/v/typic.svg)](https://crates.io/crates/typic/0.1.0)Just import it and replace your `#[repr(...)]` attributes with `#[typic::repr(...)]`:
```rust
// 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!
```[soundness]: https://docs.rs/typic/latest/typic/transmute/unsafe_transmutation
[safety]: https://docs.rs/typic/latest/typic/safe/#### 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.