hui_derive/
lib.rs

1extern crate proc_macro;
2
3use proc_macro::TokenStream;
4use quote::quote;
5use syn::{parse_macro_input, DeriveInput};
6
7/// Implements `Signal` trait for the given type
8#[proc_macro_derive(Signal)]
9pub fn derive_signal(input: TokenStream) -> TokenStream {
10  let input = parse_macro_input!(input as DeriveInput);
11  let name = input.ident;
12  quote!(impl ::hui::signal::Signal for #name {}).into()
13}
14
15/// Implements `State` trait for the given type
16#[proc_macro_derive(State)]
17pub fn derive_state(input: TokenStream) -> TokenStream {
18  let input = parse_macro_input!(input as DeriveInput);
19  let name = input.ident;
20  quote!(impl ::hui::state::State for #name {}).into()
21}