educe/trait_handlers/into/
mod.rs

1mod common;
2mod into_enum;
3mod into_struct;
4mod models;
5mod panic;
6
7use syn::{Data, DeriveInput, Meta};
8
9use super::TraitHandlerMultiple;
10use crate::Trait;
11
12pub(crate) struct IntoHandler;
13
14impl TraitHandlerMultiple for IntoHandler {
15    #[inline]
16    fn trait_meta_handler(
17        ast: &DeriveInput,
18        token_stream: &mut proc_macro2::TokenStream,
19        traits: &[Trait],
20        meta: &[Meta],
21    ) -> syn::Result<()> {
22        match ast.data {
23            Data::Struct(_) => {
24                into_struct::IntoStructHandler::trait_meta_handler(ast, token_stream, traits, meta)
25            },
26            Data::Enum(_) => {
27                into_enum::IntoEnumHandler::trait_meta_handler(ast, token_stream, traits, meta)
28            },
29            Data::Union(_) => {
30                Err(crate::panic::trait_not_support_union(meta[0].path().get_ident().unwrap()))
31            },
32        }
33    }
34}