const_struct 0.5.4

macro that allows const structures to be passed as const generics
Documentation

const_struct

This crate provides a way to create a struct with const generics and const values.

use const_struct::{primitive::F32Ty, F32};
pub fn tester<A: F32Ty>() {
    println!("a: {:?}", A::__DATA);
}
fn main() {
    tester::<F32!(0.5)>();
}

This crate is no_std. used unsafe code:

  • core::mem::zeroed
  • core::mem::transmute

See the Github README for more information.