Declare an Enum inline with a struct declaration

Viewed 268

I could have a structure like the following:

struct Example {
    state: State,
    properties: HashMap<String, String>,
}

enum State {
    a, b, c,
}

If the Example structure is the only user of the State enum, I think it would make sense to declare it in the struct:

struct Example {
    state: enum { a, b, c },
    properties: HashMap<String, String>,
}

Is there any valid syntax for this?

1 Answers
Related