Skip to main content

scrutiny_derive/
lib.rs

1use proc_macro::TokenStream;
2use syn::{DeriveInput, parse_macro_input};
3
4mod codegen;
5mod parse;
6
7#[proc_macro_derive(Validate, attributes(validate))]
8pub fn derive_validate(input: TokenStream) -> TokenStream {
9    let input = parse_macro_input!(input as DeriveInput);
10    match codegen::expand(input) {
11        Ok(tokens) => tokens.into(),
12        Err(err) => err.to_compile_error().into(),
13    }
14}