Hello,
Say I have hundreds of struct
s that look like this:
struct doge {
x: u8
y: u32
z: String
a: u16
...
}
In this, doge.x
can have any value between 1 and 255.
Each value is associated with a different meaning/message.
Consider that I'll have 2 programs - one to parse some binary data (i.e., read fields like doge.x
), and another to make the parsed data human-friendly.
For the 2nd program, is it ideal to store the associated meaning aka message text in a HashMap
, serving as a look-up table, so that when printing out a report, it'll say x - message text for x
rather than x - 1
.
I understand that this probably means making many many copies of that message text when printing out.
HashMap with content like:
doge.x.1 - message for text doge.x.1
doge.x.2 - message for text doge.x.2
doge.x.3 - message for text doge.x.3
doge.x.4 - message for text doge.x.4
...
doge.x.255 - message for text doge.x.255
Is there a better way of doing this?
Please do let me know if any clarification is needed in the scenario I've explained above.
Thanks as always for your feedback.