quicktype-vscode icon indicating copy to clipboard operation
quicktype-vscode copied to clipboard

generate Rust file missing an keyword such as `pub`

Open cnzf1 opened this issue 2 years ago • 0 comments

When I use JSON to Rust generate a file like below:

pub struct Record{
    #[serde(rename = "CODE")]
    code: String,

    #[serde(rename = "SECURITY_CODE")]
    security_code: String,

    #[serde(rename = "NAME")]
    name_abbr: String,
}

But, when I should access the field , I should get a error ,because of it is not visibility。I need a result like this:

pub struct Record{
    #[serde(rename = "CODE")]
    pub code: String,

    #[serde(rename = "SECURITY_CODE")]
    pub security_code: String,

    #[serde(rename = "NAME")]
    pub name_abbr: String,
}

If had a switch to control the soft , whether generate the keywork pub, it should be more perfect.

cnzf1 avatar Jul 07 '23 08:07 cnzf1