Recommended way to converting an integer to Enum

I researched a little bit and there seems to be at least 2 ways.

  1. Use enum_primitive.

  2. Use num_derive and num_traits.
    How do I match enum values with an integer?
    has a discussion on this.

Both approaches leverage very popular crates. I wonder which way is preferred? What are the differences between those 2 approaches?

You can also write a conversion method that uses a match.

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.