#[derive(ConstAssoc)]
{
// Attributes available to this derive:
#[const_assoc]
}
Expand description
Adds associated constants to a type via an inherent impl block.
ยงExample
#[derive(mkutils_macros::ConstAssoc)]
#[const_assoc(pub MAX_SIZE: usize = 1024)]
#[const_assoc(DEFAULT_NAME: &str = "unnamed")]
struct MyStruct;
// adds
// ```rust
// impl MyStruct {
// pub const MAX_SIZE: usize = 1024;
// const DEFAULT_NAME: &str = "unnamed";
// }
// ```
// as can be seen in
std::assert_eq!(MyStruct::MAX_SIZE, 1024);
std::assert_eq!(MyStruct::DEFAULT_NAME, "unnamed");