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

Rust Serde option conflicting with names #373

Open
DynamicCake opened this issue Jul 19, 2023 · 0 comments
Open

Rust Serde option conflicting with names #373

DynamicCake opened this issue Jul 19, 2023 · 0 comments

Comments

@DynamicCake
Copy link

If you do

{
    "options": [
        {
            "a": 1
        },
        {
            "b": 2
        }
    ]
}

It will output

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Root {
    pub options: Vec<Option>, 
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Option { // Here
    pub a: Option<i64>,
    pub b: Option<i64>,
}

Which conflicts with std option

I suggest using an import alias like
use std::option::Option as StdOption;
but I am not sure what to do if the user uses StdOption

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

No branches or pull requests

1 participant