newnit_derive 0.1.2

A derive macro package for the Newnit library.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use darling::FromDeriveInput;
use proc_macro::TokenStream;
use proc_macro2::{Ident, Span};

use crate::impl_quantity::{QuantityArgs, impl_quantity};

pub fn derive(ast: &syn::DeriveInput) -> TokenStream {
    let args = QuantityArgs::from_derive_input(ast).expect("Failed parsing derive arguments.");

    let unit = &ast.ident;

    let quantity = Ident::new("Velocity", Span::call_site());

    impl_quantity(unit, &quantity, &args)
}