Hello, I have many values I want to put in an array. Instead of referencing them by number , Id like to give each one a name like in c++, where the compiler takes care of it. Is this possible in Rust?
Well you can:
- Define an enum. If the enum has no fields, then you can cast it to an integer.
- Define a bunch of constants and use the constants as index.
- Instead of an array, define a struct with named fields of the same type.
2 Likes
I´ll look into that. Thank you very much for your fast reply.
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.