Let's say you name your field e.g. offset or value. This will currently fail with some random error, because we already use these variable names and so they get shadowed.
Funny enough, it's kinda like an user string injection attack.
To fix this, we either need to use more obscure names, like ____offset, or rename the passed-in field arguments at the top of the constructor to something which is not user-supplied, like arg_offset, arg_value. I like the second one more, since cargo expand should look more readable.
On the topic of readability, currently in constructors we do:
let raw_value = {
//...
} | {
//...
} | //...
Which should be more like:
let shifted_offset = { ... };
//...
let raw_value = shifted_offset | shifted_value | shifted_field3;
Let's say you name your field e.g.
offset
orvalue
. This will currently fail with some random error, because we already use these variable names and so they get shadowed.Funny enough, it's kinda like an user string injection attack.
To fix this, we either need to use more obscure names, like
____offset
, or rename the passed-in field arguments at the top of the constructor to something which is not user-supplied, likearg_offset, arg_value
. I like the second one more, sincecargo expand
should look more readable.On the topic of readability, currently in constructors we do:
Which should be more like: