prefixes_ms/
lib.rs

1//! A procedural macro that allows you to use the `ms` attribute to create a `Duration` from a number of milliseconds.
2//! Part of the [prefixes](https://crates.io/crates/prefixes) crate.
3
4use proc_macro::TokenStream;
5use quote::quote;
6use syn::{parse_macro_input, LitInt};
7
8#[proc_macro_attribute]
9pub fn ms(_: TokenStream, input: TokenStream) -> TokenStream {
10    let input = parse_macro_input!(input as LitInt);
11
12    quote! { ::core::time::Duration::from_millis(#input) }.into()
13}