Anonymous/struct-local enums

May be it's in the language, but I wasn't able to find it. Are there an ability to create per-structure enums?

(This code does not compile).

pub struct Value{
    x: f64,
    y: f64,
    type: enum {

This enum is never used outside of the structure, so it would be nice to have it declared inside structure.

Is there a way to do something like this?

This feature doesn't exist. The enum can easily be declared as a private enum next to the struct - and then you can add the required derives/trait impls it too, once the type has a name (you'll find that this is close to mandatory, let's say if you for example want the enum values to be Copy).


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.