Skip to content

Commit

Permalink
add occurence errros
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmcbride committed Feb 26, 2023
1 parent 453b76a commit 2d47a85
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion strum_macros/src/helpers/inner_variant_props.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::metadata::{InnerVariantExt, InnerVariantMeta};
use super::occurrence_error;
use syn::{Field, LitStr};

pub trait HasInnerVariantProperties {
Expand All @@ -14,9 +15,14 @@ impl HasInnerVariantProperties for Field {
fn get_variant_inner_properties(&self) -> syn::Result<StrumInnerVariantProperties> {
let mut output = StrumInnerVariantProperties { default_with: None };

let mut default_with_kw = None;
for meta in self.get_named_metadata()? {
match meta {
InnerVariantMeta::DefaultWith { kw: _, value } => {
InnerVariantMeta::DefaultWith { kw, value } => {
if let Some(fst_kw) = default_with_kw {
return Err(occurrence_error(fst_kw, kw, "default_with"));
}
default_with_kw = Some(kw);
output.default_with = Some(value);
}
}
Expand Down

0 comments on commit 2d47a85

Please sign in to comment.