I need help converting the following C code to Rust.
#define v0 0x0
#define v1 0x1
#define v2 0x2
#define v3 0x3
struct arr {
u_int v;
const char *s;
};
static const struct arr str[] = {
{ v0, "zero" },
{ v1, "one" },
{ v2, "two" },
{ v3, "three" },
{ 0, NULL }
};
I have the following Rust code already done, but I can't figure out the best way to create an array of structs like the C code does.
static v0: u8 = 0;
static v1: u8 = 1;
static v2: u8 = 2;
static v3: u8 = 3;
struct arr {
v: u8,
s: &'static str,
}
I have tried the following code, but to no success:
static str: [arr; 4] = [
{
v: v0,
s:"zero",
},
{
v: v1,
s:"one",
},
{
v: v2,
s:"two",
},
{
v: v3,
s:"three",
},
];