strum_macros/helpers/
mod.rs1pub use self::case_style::{CaseStyleHelpers, snakify};
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(), "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 "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 = 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}