Closed harryfei closed 4 years ago
I would love to. I haven't been following proc_macros
though, are they going to be stable soon? I probably won't do anything until they're in stable
Rust 1.30 (including proc macro) is released now.
I was having some issues with rust complaining that it couldn't figure out what type to use for return values with the regular macro so I decided to give this a shot.
Here's the list of attributes that I'm working on (all of these are optional)
String
- cache name (default is uppercase of function name)usize
- use sized cacheu64
- use timed cacheType
" - the type to be used for the cache (required when convert is set)Block
" - use a block to convert inputs into the key (required when key is set)Ok
Some
I'm using darling for the attributes parsing and it doesn't implement parsing Type
or Block
so right now the key type and convert block both have to be put in a string and parsed separately.
I should have the unwrap attribute implemented on Friday or Saturday. Once I have that done I'll fork, add the proc macro as a sub crate, and make a pull request.
Edit: I realized that having one attribute for both result and option wouldn't work since it would have to be based on parsing out the return type name and the user could have aliased the result/option type or be using their own. I changed it to be separate result/option attributes.
I finished with this set of attributes, now I'm going fork and add as a subcrate. I'm using the visibility of the input function for the output function and cache so this should also fix #15.
Do you have a plan to rebuild the macros based on the proc_macro?
Those are sweeter.