glib_macros/downgrade_derive/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Take a look at the license at the top of the repository in the LICENSE file.

mod enums;
mod fields;
mod structs;

use proc_macro::TokenStream;
use syn::{Data, DeriveInput};

pub fn impl_downgrade(input: DeriveInput) -> TokenStream {
    match input.data {
        Data::Struct(data_struct) => {
            structs::derive_downgrade_for_struct(input.ident, input.generics, data_struct)
        }
        Data::Enum(data_enum) => {
            enums::derive_downgrade_for_enum(input.ident, input.generics, data_enum)
        }
        Data::Union(..) => {
            panic!("#[derive(Downgrade)] is not available for unions.");
        }
    }
}