hipcheck_macros/lib.rs
1// SPDX-License-Identifier: Apache-2.0
2
3// Use the `README.md` as the crate docs.
4#![doc = include_str!("../README.md")]
5
6mod update;
7
8use proc_macro::TokenStream;
9use syn::{parse_macro_input, DeriveInput, Error};
10
11/// Derive an implementation of the `Update` trait for the type.
12#[proc_macro_derive(Update)]
13pub fn derive_update(input: TokenStream) -> TokenStream {
14 // Parse the input.
15 let input = parse_macro_input!(input as DeriveInput);
16
17 // Generate the token stream.
18 update::derive_update(input)
19 .unwrap_or_else(Error::into_compile_error)
20 .into()
21}