macro_rules! define_validated_struct_type {
(
$StructName:ident,
$PolicyType:ident,
$RawType:ident,
$doc:literal,
$display_string:literal
) => { ... };
}Expand description
Defines the validated struct with documentation and serialization support.
Creates a #[repr(transparent)] newtype wrapper around the raw type with:
- Automatic
AsRef,Debug,Display,LowerExpderives - Serde
SerializeandDeserializesupport - Phantom data for kernel type
§Example
ⓘ
define_validated_struct_type!(
RealValidated,
RealPolicy,
RawReal,
"A validated real number wrapper",
"{value}"
);§Parameters
$StructName: Name of the struct (e.g.,RealValidated)$PolicyType: Policy field inNumKernel(e.g.,RealPolicy)$RawType: Raw value type (e.g.,RawReal)$doc: Documentation string$display_string: Format string for Display/LowerExp (e.g.,"{value}")