syn_prelude_macros/
lib.rs1use match_keyword_cases::MatchKeywordCases;
2use peek_keyword_in_condition::PeekKeywordInCondition;
3use quote::ToTokens;
4use repeat_keyword_lit_and_types::RepleatKeywordLitAndTypes;
5
6mod common;
7mod match_keyword_cases;
8mod path_helpers;
9mod peek_keyword_in_condition;
10mod repeat_keyword_lit_and_types;
11mod to_span;
12mod try_parse_one_of_idents;
13
14pub(crate) const KEYWORDS: [&'static str; 50] = [
15 "abstract", "as", "async", "auto", "await", "become", "box", "break", "const", "continue",
16 "crate", "default", "do", "dyn", "else", "enum", "extern", "final", "fn", "for", "if", "impl",
17 "in", "let", "loop", "macro", "match", "mod", "move", "mut", "override", "priv", "pub", "ref",
18 "return", "static", "struct", "super", "trait", "try", "type", "typeof", "union", "unsafe",
19 "unsized", "use", "virtual", "where", "while", "yield",
20];
21
22#[proc_macro]
41pub fn repeat_keyword_lit_and_types(s: proc_macro::TokenStream) -> proc_macro::TokenStream {
42 match syn::parse::<RepleatKeywordLitAndTypes>(s) {
43 Ok(s) => s.to_token_stream().into(),
44 Err(err) => err.to_compile_error().into(),
45 }
46}
47
48#[proc_macro]
65pub fn match_keyword_cases(s: proc_macro::TokenStream) -> proc_macro::TokenStream {
66 match syn::parse::<MatchKeywordCases>(s) {
67 Ok(s) => s.to_token_stream().into(),
68 Err(err) => err.to_compile_error().into(),
69 }
70}
71
72#[proc_macro]
73pub fn peek_keyword_in_condition(s: proc_macro::TokenStream) -> proc_macro::TokenStream {
74 match syn::parse::<PeekKeywordInCondition>(s) {
75 Ok(s) => s.to_token_stream().into(),
76 Err(err) => err.to_compile_error().into(),
77 }
78}
79
80#[proc_macro]
81pub fn gen_tuples_for_impl_ident_names(s: proc_macro::TokenStream) -> proc_macro::TokenStream {
82 match syn::parse::<common::TupleGen>(s) {
83 Ok(s) => s.gen_tuples_for_impl_ident_names().into(),
84 Err(err) => err.to_compile_error().into(),
85 }
86}
87
88#[proc_macro]
89pub fn gen_tuples_for_impl_to_span(s: proc_macro::TokenStream) -> proc_macro::TokenStream {
90 match syn::parse::<common::TupleGen>(s) {
91 Ok(s) => s.gen_tuples_for_impl_to_span().into(),
92 Err(err) => err.to_compile_error().into(),
93 }
94}
95
96#[proc_macro]
97pub fn gen_tuples_for_impl_into_idents(s: proc_macro::TokenStream) -> proc_macro::TokenStream {
98 match syn::parse::<common::TupleGen>(s) {
99 Ok(s) => s.gen_tuples_for_impl_into_idents().into(),
100 Err(err) => err.to_compile_error().into(),
101 }
102}