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

[toml] Rename attribute includes double quotes when resulting name contains dots #2717

Open
Gigas002 opened this issue Mar 22, 2024 · 0 comments

Comments

@Gigas002
Copy link

Code sample:

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Config {
    pub keybindings: Option<String>,
    #[serde(rename = "clipboard")]
    pub clipboard: Option<String>,
    #[serde(rename = "screenshot.filesystem")]
    pub filesystem: Option<String>,
}

impl Default for Config {
    fn default() -> Self {
        Config {
            keybindings: Some("hello".to_string()),
            clipboard: Some("toml".to_string()),
            filesystem: Some("serde".to_string()),
        }
    }
}

fn main() {
    let config = Config::default();
    let serialized = toml::to_string_pretty(&config).unwrap();
    let mut file = File::create("output.toml").unwrap();
    file.write_all(serialized.as_bytes()).unwrap();
}

This code produces this output:

keybindings = "hello"
clipboard = "toml"
"screenshot.filesystem" = "serde"

Not sure if it's serde or toml crate's problem, though...

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

1 participant