toml-lang / toml

Tom's Obvious, Minimal Language
https://toml.io
MIT License
19.45k stars 847 forks source link

tuple struct with mixed types serializes but fails to deseralize #907

Closed 0rphon closed 2 years ago

0rphon commented 2 years ago

feel free to close if its a duplicate, but i didnt see this filed anywhere

use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Default)]
struct Hack(u32, String);

fn main() {
    let x = Hack::default();
    // works
    let y = toml::to_string(&x).unwrap();
    // fails
    let _: Hack = toml::from_str(&y).unwrap();
}
0rphon@iPhone:~/Coding/playground$ cargo run
   Compiling serde v1.0.137
   Compiling toml v0.5.9
   Compiling playground v0.1.0 (/home/0rphon/Coding/playground)
    Finished dev [unoptimized + debuginfo] target(s) in 3.17s
     Running `target/debug/playground`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { inner: ErrorInner { kind: Wanted { expected: "a right bracket", found: "a comma" }, line: Some(0), col: 2, at: Some(2), message: "", key: [] } }', src/main.rs:9:38
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
marzer commented 2 years ago

This is the repository for the TOML language, not any particular implementation. Looks like you want this instead: https://github.com/alexcrichton/toml-rs