Create a new value in Enum

Is possible create a new value inside an Enum type ?
E.g:

enum Weapon {
 Sword,
 Axe,
 Bow,
}

I want insert a knife into.

Is the enum Weapon defined in your crate? If so, just insert new variant and fix compile errors if exist. If not, you can't break other crate's public interface.

2 Likes

You can wrap the enum:

enum NewWeapon {
   Classic(Weapon),
   Lasers,
   Blasters,
}
6 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.