Skip to content
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 rename of container with &'static str #2485

Open
DanielBauman88 opened this issue Jun 27, 2023 · 1 comment
Open

Allow rename of container with &'static str #2485

DanielBauman88 opened this issue Jun 27, 2023 · 1 comment

Comments

@DanielBauman88
Copy link

Since the last issue #450 was closed there seems to have been a fair bit of interest.
The last two comments referring to implementing this functionality have 4 and 11 "+1"s.

Additionally, it seems like this would now be doable without needing a new attribute like rename_const.

In light of this now being supported, I think this is worth re-opening.

@Victor-N-Suadicani
Copy link

Victor-N-Suadicani commented Mar 27, 2024

I just ran into this as I tried doing something like this:

trait FieldName {
    const FIELD_NAME: &'static str;
}

#[derive(Serialize, Deserialize)]
struct MyStruct<T: FieldName> {
    #[serde(rename = T::FIELD_NAME)]
    renamed_field: i32,
}

I honestly just assumed this would work but unfortunately it doesn't 😞.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants