Skip to content

Commit

Permalink
Implement property hint string for bit flags (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
TitanNano committed Jun 26, 2024
1 parent da275fb commit d613594
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions derive/src/attribute_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,21 @@ impl FieldExportOps {
result = Some((field, quote!(#property_hints::FILE), filters.join(",")));
}

if self.flags.is_some() {
if let Some(list) = self.flags.as_ref() {
let field = "flags";

if let Some((active_field, _, _)) = result {
return Self::error(span, active_field, field);
}

result = Some((field, quote!(#property_hints::FLAGS), String::new()));
let flags = list
.elems
.iter()
.map(String::from_expr)
.collect::<Result<Vec<_>, _>>()
.map_err(|err| err.write_errors())?;

result = Some((field, quote!(#property_hints::FLAGS), flags.join(",")));
}

if self.global_dir {
Expand Down

0 comments on commit d613594

Please sign in to comment.