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
Rename With Expressions #1964
Comments
Maybe add a new attribute like What data types do you think should be allowed in this case? It seems to me better to restrict ourselves only to the associated constants. My use case: struct IssuesBatchResponse {
issues: Vec<Issue>,
total_count: u64,
offset: u64,
limit: u64,
} As you can see, the 'issues' key is specified for a specific site endpoint. Other keys are given for the rest of the data types. It would be nice to do something like the example below to reduce duplication of structures and code: struct BatchResponse<S> {
#[serde(rename_with = "S::NAME")]
payload: Vec<S>,
total_count: u64,
offset: u64,
limit: u64
} |
a much use case case is when the struct is defined in a decl macro and the rename is the result of a |
Currently
rename = ?
attributes are parsed asLitStr
, which precludes using constant expressions instead of literals.My concrete use case is a proc macro that needs to set renames based on an external constant.
For example:
I would be happy to implement this, but I'd like to know beforehand if this would be accepted, which is probably not a given due to the added complexity.
( @dtolnay )
The text was updated successfully, but these errors were encountered: