Mercurial > lbo > hg > memoize
changeset 43:a9b3e08f1ae5
Remove unused_import warning and run rustfmt
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Thu, 10 Dec 2020 20:22:32 +0100 |
parents | 530ed8152c95 |
children | b73c35db6c4b |
files | src/lib.rs |
diffstat | 1 files changed, 14 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib.rs Thu Dec 10 19:23:52 2020 +0100 +++ b/src/lib.rs Thu Dec 10 20:22:32 2020 +0100 @@ -1,11 +1,10 @@ #![crate_type = "proc-macro"] +#![allow(unused_imports)] // Spurious complaints about a required trait import. -use syn; -use syn::{parse_macro_input, spanned::Spanned, ItemFn}; +use syn::{self, export::ToTokens, parse_macro_input, spanned::Spanned, ItemFn}; use proc_macro::TokenStream; use quote::{self}; -use syn::export::ToTokens; // This implementation of the storage backend does not depend on any more crates. #[cfg(not(feature = "full"))] @@ -47,9 +46,8 @@ #[cfg(feature = "full")] mod store { use proc_macro::TokenStream; + use syn::export::ToTokens; use syn::{parse as p, Expr}; - use syn::export::ToTokens; - #[derive(Default, Clone)] pub(crate) struct CacheOptions { @@ -267,21 +265,21 @@ hm.#insert_fn(#syntax_names_tuple, (std::time::Instant::now(), r.clone())); r } - } + }, } }; #[cfg(not(feature = "full"))] let memoizer = quote::quote! { - #sig { - let mut hm = &mut #store_ident.lock().unwrap(); - if let Some(r) = hm.#get_fn(&#syntax_names_tuple_cloned) { - return r.clone(); - } - let r = #memoized_id(#(#input_names.clone()),*); - hm.#insert_fn(#syntax_names_tuple, r.clone()); - r - } - }; + #sig { + let mut hm = &mut #store_ident.lock().unwrap(); + if let Some(r) = hm.#get_fn(&#syntax_names_tuple_cloned) { + return r.clone(); + } + let r = #memoized_id(#(#input_names.clone()),*); + hm.#insert_fn(#syntax_names_tuple, r.clone()); + r + } + }; (quote::quote! { #store