betterunion

Crates.iobetterunion
lib.rsbetterunion
version0.1.1
created_at2025-08-30 17:40:36.297882+00
updated_at2025-08-30 20:51:36.297722+00
descriptionThis crate provides a safe union-like structure which uses the turbofish operator for reads and writes.
homepage
repository
max_upload_size
id1817797
size7,128
(WebAppEnjoyer)

documentation

README

Betterunion

betterunion is crate which provides a safe zero-cost way of storing types as raw data which can later be reinterpreted, only types which implement bytemuck's Pod trait can be used in the read and write functions.

Example:

use betterunion::BetterUnion;

fn main() {
    let mut u = BetterUnion::<8>::new();
    u.write(42u32);
    println!("{}", u.read_copy::<u64>());

    let mut v = BetterUnion::<16>::new();
    v.write(3.14f64);
    println!("{}", v.read_copy::<f64>());
}
Commit count: 0

cargo fmt