GithubHelp home page GithubHelp logo

Comments (5)

Peternator7 avatar Peternator7 commented on May 20, 2024

That's a good idea, and it shouldn't be too hard to add a ToString implementation. I might be able to get to it this weekend.

The rename and alias feature mostly already exists in the form of serialize. It would be nice to have some way of identifying the preferred serialization though. I'll think about this as well.

from strum.

lucab avatar lucab commented on May 20, 2024

Oh great 👍 I'll watch for this as I prefer to have a single library doing this instead of rolling it by myself n-times.

I've read about the multi-entry serialize, but here you need some kind of "leader-selection" to string-ify. rename comes from serde while alias it's just a random suggestion of mine. Feel free to pick whatever you think suits better, I'd just like to be able to have a single field for both ToString and FromString.

from strum.

Peternator7 avatar Peternator7 commented on May 20, 2024

Hey @lucab,

I merged changes into master. I couldn't find a keyword I was in love with; I wanted to stay in the spirit of serialize, but nothing felt super good so I settled on to_string="..." The updated docs explain how it works, but here's the short version. FromString will include both serialize and to_string (a bit confusing I know) when it's attempting to parse a string. ToString will prefer to_string if it is present when converting an enum into a string.

from strum.

lucab avatar lucab commented on May 20, 2024

Thanks, I'll give 0.6.0 a try.

from strum.

lucab avatar lucab commented on May 20, 2024

Adopted in camallo/dkregistry-rs#17, this suits what I was looking for. Closing.

from strum.

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.