changeset 2:112b5335a4a0

Fix warnings
author Lewin Bormann <lbo@spheniscida.de>
date Thu, 15 Oct 2020 12:53:52 +0200
parents df9526623f04
children 0bc33bd08f39
files src/lib.rs
diffstat 1 files changed, 1 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib.rs	Thu Oct 15 12:52:23 2020 +0200
+++ b/src/lib.rs	Thu Oct 15 12:53:52 2020 +0200
@@ -5,7 +5,6 @@
 
 use lazy_static::lazy_static;
 use proc_macro::TokenStream;
-use proc_macro2::Span;
 use quote::{self, ToTokens};
 
 use std::collections::HashMap;
@@ -24,7 +23,6 @@
     let func = parse_macro_input!(item as ItemFn);
     let sig = &func.sig;
 
-    let original_name = &func.sig.ident;
     let fn_name = &func.sig.ident.to_string();
     let renamed_name = format!("memoized_original_{}", fn_name);
     let map_name = format!("memoized_mapping_{}", fn_name);
@@ -65,7 +63,7 @@
     }
 
     let type_in = type_in.unwrap();
-    let map_ident = syn::Ident::new(&map_name, sig.span());
+    let map_ident = syn::Ident::new(&map_name.to_uppercase(), sig.span());
     let store = quote::quote! {
         lazy_static::lazy_static! {
             static ref #map_ident : std::sync::Mutex<std::collections::HashMap<#type_in, #type_out>> =
@@ -104,17 +102,6 @@
     static ref STORE: Mutex<HashMap<i32, bool>> = Mutex::new(HashMap::new());
 }
 
-// fn memoizer(a: i32) -> bool {
-//    let mut hm = &mut STORE.lock().unwrap();
-//    if let Some(r) = hm.get(&a) {
-//        return *r;
-//    }
-//    let r = memoized_function(a);
-//    hm.insert(a, r);
-//    r
-// }
-
 #[cfg(test)]
 mod tests {
-    use super::*;
 }