komito_derive/lib.rs
1//! This crate implements internal macros for the `komito` library.
2
3mod combine;
4
5use proc_macro::TokenStream;
6use syn::{DeriveInput, parse_macro_input};
7
8/// Automatically derives a `komito::Combine` implementation for the attributed type
9/// that calls `komito::Combine::combine` for each field.
10///
11/// The derive macro can only be used on structs. Enums aren't yet supported.
12#[proc_macro_derive(Combine)]
13pub fn derive_combine(input: TokenStream) -> TokenStream {
14 let input = parse_macro_input!(input as DeriveInput);
15
16 combine::derive_impl(input)
17 .unwrap_or_else(syn::Error::into_compile_error)
18 .into()
19}