1 pub use self::case_style::{CaseStyleHelpers, snakify};
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
non_enum_error() -> syn::Error14 pub fn non_enum_error() -> syn::Error {
15 syn::Error::new(Span::call_site(), "This macro only supports enums.")
16 }
17
strum_discriminants_passthrough_error(span: &impl Spanned) -> syn::Error18 pub fn strum_discriminants_passthrough_error(span: &impl Spanned) -> syn::Error {
19 syn::Error::new(
20 span.span(),
21 "expected a pass-through attribute, e.g. #[strum_discriminants(serde(rename = \"var0\"))]",
22 )
23 }
24
occurrence_error<T: ToTokens>(fst: T, snd: T, attr: &str) -> syn::Error25 pub fn occurrence_error<T: ToTokens>(fst: T, snd: T, attr: &str) -> syn::Error {
26 let mut e = syn::Error::new_spanned(
27 snd,
28 format!("Found multiple occurrences of strum({})", attr),
29 );
30 e.combine(syn::Error::new_spanned(fst, "first one here"));
31 e
32 }
33