• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // This file is part of ICU4X. For terms of use, please see the file
2 // called LICENSE at the top level of the ICU4X source tree
3 // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4 
5 //! Proc macros for generating `ULE`, `VarULE` impls and types for the `zerovec` crate
6 
7 use proc_macro::TokenStream;
8 use syn::{parse_macro_input, DeriveInput, Ident};
9 mod make_ule;
10 mod make_varule;
11 pub(crate) mod ule;
12 mod utils;
13 mod varule;
14 
15 /// Full docs for this proc macro can be found on the [`zerovec`](docs.rs/zerovec) crate.
16 #[proc_macro_derive(ULE)]
ule_derive(input: TokenStream) -> TokenStream17 pub fn ule_derive(input: TokenStream) -> TokenStream {
18     let input = parse_macro_input!(input as DeriveInput);
19     TokenStream::from(ule::derive_impl(&input))
20 }
21 
22 /// Full docs for this proc macro can be found on the [`zerovec`](docs.rs/zerovec) crate.
23 #[proc_macro_derive(VarULE)]
varule_derive(input: TokenStream) -> TokenStream24 pub fn varule_derive(input: TokenStream) -> TokenStream {
25     let input = parse_macro_input!(input as DeriveInput);
26     TokenStream::from(varule::derive_impl(&input, None))
27 }
28 
29 /// Full docs for this proc macro can be found on the [`zerovec`](docs.rs/zerovec) crate.
30 #[proc_macro_attribute]
make_ule(attr: TokenStream, item: TokenStream) -> TokenStream31 pub fn make_ule(attr: TokenStream, item: TokenStream) -> TokenStream {
32     let input = parse_macro_input!(item as DeriveInput);
33     let attr = parse_macro_input!(attr as Ident);
34     TokenStream::from(make_ule::make_ule_impl(attr, input))
35 }
36 
37 /// Full docs for this proc macro can be found on the [`zerovec`](docs.rs/zerovec) crate.
38 #[proc_macro_attribute]
make_varule(attr: TokenStream, item: TokenStream) -> TokenStream39 pub fn make_varule(attr: TokenStream, item: TokenStream) -> TokenStream {
40     let input = parse_macro_input!(item as DeriveInput);
41     let attr = parse_macro_input!(attr as Ident);
42     TokenStream::from(make_varule::make_varule_impl(attr, input))
43 }
44