Skip to content

Commit ac8d518

Browse files
committedNov 16, 2024
code changes for previous review
1 parent e5aafe5 commit ac8d518

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed
 

‎src/mapper_entry.rs

+18-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use syn::{
44
};
55

66
use crate::utils;
7+
use crate::utils::isblank;
78

89
pub type MapTuple = (String, bool);
910
#[derive(Debug, Default)]
@@ -239,6 +240,17 @@ impl MapperEntry {
239240
}
240241

241242
fn parse_macro_attr_attribute(mapper_entry: &mut MapperEntry, expr_arr: &ExprArray) {
243+
if mapper_entry
244+
.macro_attr
245+
.iter()
246+
.find(|attr| isblank(attr))
247+
.is_some()
248+
{
249+
panic!(
250+
"`{}` attribute must not be empty. Remove it if it's not needed. {:?}",
251+
MACRO_ATTR, mapper_entry.macro_attr
252+
);
253+
}
242254
mapper_entry.macro_attr = Self::parse_array_of_macro_attr(expr_arr);
243255
//println!("{:?}",mapper_entry.new_fields);
244256
}
@@ -365,16 +377,17 @@ impl MapperEntry {
365377
if let Some(colon_position) = field_decl.find(":") {
366378
// eprintln!("field_decl={}", field_decl);
367379
// eprintln!("colon={}", colon_position);
380+
let new_field_attr = match attributes.is_empty() {
381+
true => None,
382+
false => Some(attributes.clone()),
383+
};
384+
368385
Self::insert_next_field_value(
369386
&mut vec_tuple,
370387
field_value.clone(),
371388
field_decl,
372389
&colon_position,
373-
if attributes.is_empty() {
374-
None
375-
} else {
376-
Some(attributes.clone())
377-
},
390+
new_field_attr,
378391
);
379392
} else {
380393
panic!("Missing `:` character for field declaration");

0 commit comments

Comments
 (0)