mozilla/rust — Issue #1790: Change enum's values
Author: Aluminium95
Created: 2012-02-09 08:29:56+00:00
State: open

We have to use `enum` to make a recursive type.
But `enum`'s values can't be accessed except by a destructuring matching pattern.
And even with it, they can't be changed... (or I don't know how to)

Is it possible to make a syntax to change an `enum` value like this ?

```
enum Foo { Bar (int, float) }
let a : Foo = Bar (10,f10);
alt a {
/**
* Catch value of the two elem in the enum
* whatever they contain
*/
Bar (first, second) {
first = 32; // this is currently not possible
second = f2; // this too
}

/**
* Catch the two value of the enum
* but only if the first equals to ten
*/
Bar (first == 10, second) {
first = second;
second = 10;
}

/**
* Catch the second value only if the first equals to ten
*/
Bar (10, second) {
second = 32;
}
}
```

Maybe we can add a modifier like `mutable` to specify that the value would be changed ?