#[derive(ConstStruct)]Expand description
This derive generates a const struct implementation from struct definitions.
This derive gen {}Ty and function can use that trait,
and function can access constant field value from trait.
If you see other complex example code,
you see https://github.com/oligamiq/const_struct/tree/main/crates/test_code
ⓘ
use const_struct::{call_with_generics, const_struct, ConstStruct};
#[derive(ConstStruct, Debug)]
pub struct TestGenerics<const T: usize> {
float: f32,
}
const COUNT: usize = 7;
#[const_struct]
const B: TestGenerics<{ COUNT }> = TestGenerics { float: 0.0 };
const fn constant<const T: usize, S: TestGenericsTy<T>>() -> f32 {
S::FLOAT
}
const FLOAT: f32 = call_with_generics!(constant::<test_generics!(BTy)>());