0

I have the following code that prompts for a color:

enum Color {
  Red,
  Yellow,
  Green,
  Blue
}

let color_response: usize = Select::with_theme(&ColorfulTheme::default())
  .with_prompt("Color")
  .default(0)
  .items(/* this takes a slice with strings. what should i put here? */)
  .interact()
  .unwrap();

let color: Color = // what to put here? should I use a match statement

I am unsure how to properly generate the enum names and index the enum to get the name from it. How can I accomplish this?

LeoDog896
  • 3,472
  • 1
  • 15
  • 40
  • 1
    You might wanna look at the crates in [this question about iterating over enums](https://stackoverflow.com/questions/21371534/in-rust-is-there-a-way-to-iterate-through-the-values-of-an-enum) – cafce25 Dec 12 '22 at 23:28

0 Answers0