I need to check my understanding again, if you don’t mind
I am working through The Rust Programming Language, and I think I understand structs and enums, but as structs are very similar to structs in C (and I do understand C I think), but enums not so much, I wanted to see if I really do understand.
Would you say my explanation is correct if I say:
A struct is a user defined type that can/will have some named fields, that can be of different types, that all exists at the same time.
An enum is a user defined type that can have either elements defined by the user, or named fields, that can be of different types, and only one exists at the same time.
Is that more or less correct?
And if it is, is there a real advantage of using an enum if you could also use a struct, other than memory consumption?