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
33
34
35
36
37
38
39
40
41
mod item_fn;
mod item_foreign_mod;
mod item_record;
use crate::fce_ast_types::FCEAst;
pub(crate) trait ParseMacroInput {
fn parse_macro_input(self) -> syn::Result<FCEAst>;
}
impl ParseMacroInput for syn::Item {
fn parse_macro_input(self) -> syn::Result<FCEAst> {
use syn::spanned::Spanned;
match self {
syn::Item::Fn(function) => function.parse_macro_input(),
syn::Item::ForeignMod(extern_mod) => extern_mod.parse_macro_input(),
syn::Item::Struct(item_struct) => item_struct.parse_macro_input(),
_ => Err(syn::Error::new(
self.span(),
"At now, #[fce] could be applied only to a function, extern block or struct",
)),
}
}
}