concision_derive/
lib.rs

1/*
2   Appellation: concision-derive <library>
3   Contrib: FL03 <jo3mccain@icloud.com>
4*/
5//! Derive macros for the concision framework.
6//!
7//! ## Overview
8//!
9//!
10#![crate_name = "concision_derive"]
11#![crate_type = "proc-macro"]
12
13extern crate proc_macro;
14extern crate quote;
15extern crate syn;
16
17pub(crate) mod ast;
18pub(crate) mod attrs;
19pub(crate) mod params;
20pub(crate) mod utils;
21
22use proc_macro::TokenStream;
23use syn::{DeriveInput, parse_macro_input};
24
25/// This macro generates a parameter struct and an enum of parameter keys.
26#[proc_macro_derive(Keyed, attributes(param))]
27pub fn keyed(input: TokenStream) -> TokenStream {
28    // Parse the input tokens into a syntax tree
29    let input = parse_macro_input!(input as DeriveInput);
30
31    let res = params::impl_params(&input);
32
33    // Return the generated code as a TokenStream
34    res.into()
35}