Currently, I want to wrote an attribute macro which is equivlent to Python's wrapper, @lru_cache
But what I could found is, wrote procedure macros, which needs another crate, seems ugly.
further, if we could add custom dependencies (e.g., in playground), it is hard for us to use procedure macros.
Is it possible to write attribute macro without procedure macros?
Is there any macros which could convert
#[cache]
fn test(a:i32)->i32{...}
to
static mut _test_cache:std::collections::HashMap<i32,i32>=HashMap::new();// suppose we could wrote it. Actually it should be something under an Arc.
fn test(a:i32){
/// SAFETY: suppose we wrote a Arc thus there is no data racing...
unsafe{*_test_cache.entry(a).or_insert({/*body of the original test function*/})}
}