Attribute Macro const_struct

Source
#[const_struct]
Expand description

This macro generates a const struct.

If you get error expected type, found constant COUNT not a type you should bracket the constant in a type ascription.

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)>());