How to get all keys, and values of enum in Rust?

I want to get all keys or values enum and print them. How I can do that?
Something similar Object.values, Object.keys in JS


It looks like everything you are doing here would be easier with strum. Along with its partner crate strum_macros, it provides procedural macros for deriving and traits for iterators, parsers, Display implementations, and a bunch of other handy things with enums.

4 Likes

Thank you, exactly what I need. :+1:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.