1 | // Take a look at the license at the top of the repository in the LICENSE file. |
2 | |
3 | mod enums; |
4 | mod fields; |
5 | mod structs; |
6 | |
7 | use proc_macro::TokenStream; |
8 | use syn::{Data, DeriveInput}; |
9 | |
10 | pub 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 | |