mirror of
https://github.com/rm-dr/datapath.git
synced 2026-02-18 15:16:58 -08:00
v0.0.3
This commit is contained in:
@@ -549,7 +549,7 @@ fn generate_common_impls(
|
||||
}
|
||||
|
||||
// Extract just the field names for struct construction
|
||||
let field_names = typed_fields.iter().map(|(name, _)| name);
|
||||
let field_names: Vec<_> = typed_fields.iter().map(|(name, _)| name).collect();
|
||||
|
||||
let datapath_impl = quote! {
|
||||
impl ::datapath::Datapath for #struct_name {
|
||||
@@ -600,6 +600,13 @@ fn generate_common_impls(
|
||||
file,
|
||||
})
|
||||
}
|
||||
|
||||
fn field(&self, name: &str) -> Option<::std::string::String> {
|
||||
match name {
|
||||
#(stringify!(#field_names) => Some(self.#field_names.to_string()),)*
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user