Closed
Description
I have been playing with rust enums recently, but I found that I can't seem to make them work the way I expect.
I defined struct variants for an enum:
pub enum Entity {
Character {
money: f64,
....
},
...
}
And I want to match on them. If I match on self, in the module, I get this:
match self {
Entity::Character(entity) => {
entity.money = ...
But I get the following error message:
error[E0532]: expected tuple struct/variant, found struct variant
types::Entity::Character
What to do? Am I doing this wrong?
PS: I know I can destructure the content of the enum, but I want to use it as if it was defined locally with the correct variant.
Metadata
Metadata
Assignees
Labels
No labels