How to best iterate over all values of an enum?

⚓ Rust    📅 2025-06-20    👤 surdeus    👁️ 5      

surdeus

Warning

This post was published 54 days ago. The information described in this article may have changed.

Hello,

I want to iterate over all values of an enum, some values hold data types, others do not.
I did some reading and the strum crate was mentioned. Is there another way to do this?
Ideally this will not need to be changed if more enums are added.
Thanks!

enum OpCode 
{ OpReturn, OpConstant(i8)} // more

8 posts - 4 participants

Read full topic

🏷️ rust_feed