-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Allow specifying what name to use for a field when using Encodable/Decodable. #15795
Conversation
cc @erickt |
I think we should have a reasonably structured plan for how we are going to make these sort of extensions to deriving, rather than just adding bits and pieces as they come up. That said, this seems mostly uncontroversial, although there's a small question about |
@huonw I don't think this should apply |
I agree with @huonw in that this seems desirable, but I would prefer a good story around customizing |
I am very much interested in having a general story around customizing |
cc me |
ping @luqmana, we talked about this offline, any updates on this? |
Closing due to inactivity, but feel free to reopen with the modifications that we talked about! If I recall correctly, the main concern was choosing a syntax here which was extensible for theoretically all deriving modes. |
Split manual.adoc into markdown files, one for each chapter. For the parts of the manual that are generated from source code doc comments, update the comments to use markdown syntax and update the code generators to write to `generated.md` files. For the weekly release, stop copying the .adoc files to the `rust-analyzer/rust-analyzer.github.io` at release time. Instead, we'll sync the manual hourly from this repository. See rust-analyzer/rust-analyzer.github.io#226 for the sync. This PR should be merged first, and that PR needs to be merged before the next weekly release. This change is based on rust-lang#15795, but rebased and updated. I've also manually checked each page for markdown syntax issues and fixed any I encountered. Co-authored-by: Lukas Wirth <lukastw97@gmail.com> Co-authored-by: Josh Rotenberg <joshrotenberg@gmail.com>
Sometimes you want to decode/encode a JSON object which has keys that are not valid rust identifiers and so you can't use
Encodable/Decodable
. This pull adds an attribute (#[encoded_name]
) which lets you specify a string to use as the key to use for a given field.Note: this isn't JSON specific, anything that uses
Encodable
orDecodable
will also be able to take advantage of this.