How to mutate the inner variant value of an enum?

I have an enum called Colors with multiple color variants

enum Colors{

And i created an instance of Red variant

 let mut h = Test::Red(10);
  *h = 22;

How to change the the inner value?

You have to pattern match on an enum in order to access the associated value(s) of the correct variant.

Any other method than using pattern match?

No. (What's wrong with a pattern 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.