macro_rules! insert_optional_fields {
($detail:expr, $source:expr, {
$($key:literal => $field:ident),* $(,)?
}) => { ... };
}Expand description
Insert optional fields from a struct into a HashMap if they exist. Skips None values automatically. Optimized to avoid redundant allocations for static strings.
Example usage:
ⓘ
insert_optional_fields!(detail, static_info, {
"PCIe Address" => pcie_address,
"PCIe Vendor ID" => pcie_vendor_id,
"PCIe Device ID" => pcie_device_id
});