You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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'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:
The text was updated successfully, but these errors were encountered: