1pub use self::case_style::CaseStyleHelpers;
2pub use self::type_props::HasTypeProperties;
3pub use self::variant_props::HasStrumVariantProperties;
4
5pub mod case_style;
6mod metadata;
7pub mod type_props;
8pub mod variant_props;
9
10use proc_macro2::Span;
11use quote::ToTokens;
12use syn::spanned::Spanned;
13
14pub fn non_enum_error() -> syn::Error {
15 syn::Error::new(Span::call_site(), message:"This macro only supports enums.")
16}
17
18pub 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
25pub 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