I\'ve written this question out many times, and have finally realized that my biggest problem is that I don\'t know how I want to represent this data, and that\'s making it
Copying a &'static str
(i.e. copying the reference only) has no cost. A deep copy of the string would be a clone and would be typed as a String
.
If &'static str
is too verbose for you, you can always define a type alias.
type Str = &'static str;
HashMap
corresponds nicely to your original map. However, if you don't need the full range of char
for the key and you don't actually need to have the value typed as a char
anywhere besides indexing the map, you should use an enum
instead, as that will restrict the legal values that can be used as keys.