Git Product home page Git Product logo

Comments (5)

harryfei avatar harryfei commented on July 30, 2024 4

Rust 1.30 (including proc macro) is released now.

https://blog.rust-lang.org/2018/10/25/Rust-1.30.0.html

from cached.

csos95 avatar csos95 commented on July 30, 2024 1

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)

  • name = String - cache name (default is uppercase of function name)
  • unbound - use unbound cache (default cache type)
  • size = usize - use sized cache
  • time = u64 - use timed cache
  • key = "Type" - the type to be used for the cache (required when convert is set)
  • convert = "Block" - use a block to convert inputs into the key (required when key is set)
  • result - only cache the result if it is Ok
  • option - only cache the result if it is 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.

from cached.

jaemk avatar jaemk commented on July 30, 2024

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

from cached.

harryfei avatar harryfei commented on July 30, 2024

Yes, it does.

rust-lang/rust#38356 (comment)

from cached.

csos95 avatar csos95 commented on July 30, 2024

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.

from cached.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.