cushy_macros/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use manyhow::{manyhow, Result};
use proc_macro2::TokenStream;
use quote_use::quote_use as quote;

#[cfg(test)]
macro_rules! expansion_snapshot {
    ($name:ident $($tokens:tt)*) => {
        #[test]
        fn $name() {
            expansion_snapshot!{$($tokens)*}
        }
    };
    (#[derive($fn:expr)]$($tokens:tt)*) => {{
        use insta::assert_snapshot;
        use prettyplease::unparse;
        use syn::{parse2, parse_quote};
        let input = parse_quote!($($tokens)*);
        let output = $fn(input).unwrap();
        match &parse2(output.clone()) {
            Ok(ok) => assert_snapshot!(unparse(ok)),
            Err(_) => panic!("{output}"),
        }
    }};
}

mod animation;
mod cushy_main;

#[manyhow(proc_macro_derive(LinearInterpolate))]
pub use animation::linear_interpolate;
#[manyhow(proc_macro_attribute)]
pub use cushy_main::main;