educe/trait_handlers/deref/
mod.rs

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