-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ericmcbride-ISSUE-245'
- Loading branch information
Showing
8 changed files
with
180 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use super::metadata::{InnerVariantExt, InnerVariantMeta}; | ||
use super::occurrence_error; | ||
use syn::{Field, LitStr}; | ||
|
||
pub trait HasInnerVariantProperties { | ||
fn get_variant_inner_properties(&self) -> syn::Result<StrumInnerVariantProperties>; | ||
} | ||
|
||
#[derive(Clone, Eq, PartialEq, Debug, Default)] | ||
pub struct StrumInnerVariantProperties { | ||
pub default_with: Option<LitStr>, | ||
} | ||
|
||
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 } => { | ||
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); | ||
} | ||
} | ||
} | ||
|
||
Ok(output) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters