-
Notifications
You must be signed in to change notification settings - Fork 5
Prefer explicit indexing over automatically assigned indices #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@AlfioEmanueleFresta Would this work for you? |
Alternatively, we could use |
@robin-nitrokey This is great, thank you! TL;DR, both options look good to me. Whilst not my favourite naming option, I would prefer adopting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small nits.
I like using the #[serde(index = ...)]
rather than rename
since if there's some subtle change with the upstream implementation it forces to pay attention when migrating.
You'd want this to replace #14 ? |
No. It’s still required for the |
Just FYI it seems unlikely that upstream |
Automatically assigning indices based on the order of the fields is error prone, for example when used with feature flags, when fields are skipped or when the fields of the struct are changed or reordered. With this patch, we require an explicit opt-in to this potentially problematic behavior. See also: #17
This PR adds an
index
attribute for explicit index assignment and makes the old automatic index assignment opt-in with theauto_index
attribute.This means that this old code
now has to be written like this:
Fixes: #17