1// Take a look at the license at the top of the repository in the LICENSE file.
2
3mod enums;
4mod fields;
5mod structs;
6
7use proc_macro::TokenStream;
8use syn::{Data, DeriveInput};
9
10pub fn impl_downgrade(input: DeriveInput) -> TokenStream {
11 match input.data {
12 Data::Struct(data_struct: DataStruct) => {
13 structs::derive_downgrade_for_struct(input.ident, input.generics, data_struct)
14 }
15 Data::Enum(data_enum: DataEnum) => {
16 enums::derive_downgrade_for_enum(input.ident, input.generics, data_enum)
17 }
18 Data::Union(..) => {
19 panic!("#[derive(Downgrade)] is not available for unions.");
20 }
21 }
22}
23