#How to optimize this code and more readable with struct or enum?

7 messages ยท Page 1 of 1 (latest)

dry tulip
#
const CMD: [[&str; 2]; 3] = [["ECHO", "echo "],
                                ["QUIT", ":q"],
                                ["HELP", "?"]];
 

feral nexus
#

Why not just have a three-value enum and a method that converts it into a string?

Alternatively, have a value of type [(MyEnum, &str); 3]

#

Actually, what do you mean by "optimize"?

sweet steppe
dry tulip
feral nexus
dry tulip
#

Oh sorry ๐Ÿ˜