1 | pub use self::case_style::CaseStyleHelpers; |
2 | pub use self::type_props::HasTypeProperties; |
3 | pub use self::variant_props::HasStrumVariantProperties; |
4 | |
5 | pub mod case_style; |
6 | mod metadata; |
7 | pub mod type_props; |
8 | pub mod variant_props; |
9 | |
10 | use proc_macro2::Span; |
11 | use quote::ToTokens; |
12 | use syn::spanned::Spanned; |
13 | |
14 | pub fn non_enum_error() -> syn::Error { |
15 | syn::Error::new(Span::call_site(), message:"This macro only supports enums." ) |
16 | } |
17 | |
18 | pub fn strum_discriminants_passthrough_error(span: &impl Spanned) -> syn::Error { |
19 | syn::Error::new( |
20 | span.span(), |
21 | message:"expected a pass-through attribute, e.g. #[strum_discriminants(serde(rename = \"var0 \"))]" , |
22 | ) |
23 | } |
24 | |
25 | pub fn occurrence_error<T: ToTokens>(fst: T, snd: T, attr: &str) -> syn::Error { |
26 | let mut e: Error = syn::Error::new_spanned( |
27 | tokens:snd, |
28 | message:format!("Found multiple occurrences of strum( {})" , attr), |
29 | ); |
30 | e.combine(another:syn::Error::new_spanned(tokens:fst, message:"first one here" )); |
31 | e |
32 | } |
33 | |