vizia_derive/
lib.rs

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