1pub use self::case_style::snakify;
2pub use self::inner_variant_props::HasInnerVariantProperties;
3pub use self::type_props::HasTypeProperties;
4pub use self::variant_props::HasStrumVariantProperties;
5
6pub mod case_style;
7pub mod inner_variant_props;
8mod metadata;
9pub mod type_props;
10pub mod variant_props;
11
12use proc_macro2::Span;
13use quote::ToTokens;
14use syn::spanned::Spanned;
15
16pub fn non_enum_error() -> syn::Error {
17 syn::Error::new(Span::call_site(), message:"This macro only supports enums.")
18}
19
20pub 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 \
24message: using it in conjunction with [`EnumDiscriminants`]",
25 )
26}
27
28pub 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
35pub 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