mirror of
https://github.com/OMGeeky/confique.git
synced 2026-01-05 03:00:25 +01:00
This was mostly what I implemented as utility library for another project. But I figured I can also extract it as it's useful on its own.
18 lines
368 B
Rust
18 lines
368 B
Rust
use proc_macro::TokenStream as TokenStream1;
|
|
|
|
|
|
mod ast;
|
|
mod gen;
|
|
mod parse;
|
|
|
|
|
|
/// Defines a configuration in a special syntax. TODO: explain what this
|
|
/// generates.
|
|
#[proc_macro]
|
|
pub fn config(input: TokenStream1) -> TokenStream1 {
|
|
syn::parse2::<ast::Input>(input.into())
|
|
.map(gen::gen)
|
|
.unwrap_or_else(|e| e.to_compile_error())
|
|
.into()
|
|
}
|