dsl_auto_type/
lib.rs

1pub mod auto_type;
2
3use proc_macro2::TokenStream;
4
5pub use auto_type::{Case, DeriveSettings};
6
7enum Error {
8    Syn(syn::Error),
9    Darling(darling::Error),
10}
11
12pub fn auto_type_proc_macro_attribute(
13    attr: TokenStream,
14    input: TokenStream,
15    config: auto_type::DeriveSettings,
16) -> TokenStream {
17    match auto_type::auto_type_impl(attr, &input, config) {
18        Ok(token_stream) => token_stream,
19        Err(e) => {
20            let mut out = input;
21            match e {
22                Error::Syn(e) => {
23                    out.extend(e.into_compile_error());
24                }
25                Error::Darling(e) => {
26                    out.extend(e.write_errors());
27                }
28            }
29            out
30        }
31    }
32}
33
34impl From<syn::Error> for Error {
35    fn from(e: syn::Error) -> Self {
36        Error::Syn(e)
37    }
38}
39impl From<darling::Error> for Error {
40    fn from(e: darling::Error) -> Self {
41        Error::Darling(e)
42    }
43}