vizia_derive/lib.rs
1#![allow(dead_code)]
2#![allow(clippy::uninlined_format_args)]
3
4// Adapted from Druid
5
6// Copyright 2019 The Druid Authors.
7//
8// Licensed under the Apache License, Version 2.0 (the "License");
9// you may not use this file except in compliance with the License.
10// You may obtain a copy of the License at
11//
12// http://www.apache.org/licenses/LICENSE-2.0
13//
14// Unless required by applicable law or agreed to in writing, software
15// distributed under the License is distributed on an "AS IS" BASIS,
16// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17// See the License for the specific language governing permissions and
18// limitations under the License.
19
20mod attr;
21mod data;
22mod lens;
23
24use proc_macro::TokenStream;
25use syn::parse_macro_input;
26
27#[proc_macro_derive(Data, attributes(data))]
28pub fn derive_data(input: TokenStream) -> TokenStream {
29 let input = parse_macro_input!(input as syn::DeriveInput);
30 data::derive_data_impl(input).unwrap_or_else(|err| err.to_compile_error()).into()
31}
32
33#[proc_macro_derive(Lens, attributes(lens))]
34pub fn derive_lens(input: TokenStream) -> TokenStream {
35 let input = parse_macro_input!(input as syn::DeriveInput);
36 lens::derive_lens_impl(input).unwrap_or_else(|err| err.to_compile_error()).into()
37}