macro_rules! extract_struct_fields {
($detail:expr, $source:expr, {
$($key:literal => $field:ident),* $(,)?
}) => { ... };
}Expand description
Extract fields from a struct and insert them into a HashMap. Useful for populating detail HashMaps from device structs. Optimized to avoid redundant allocations for static strings.
Example usage:
ⓘ
extract_struct_fields!(detail, device, {
"serial_number" => device_sn,
"firmware_version" => firmware,
"pci_bdf" => pci_bdf
});