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