toml icon indicating copy to clipboard operation
toml copied to clipboard

the order of vectors order cause ValueAfterTable

Open z-Wind opened this issue 2 years ago • 0 comments

use serde::Serialize;
use toml;

#[derive(Serialize)]
struct Outer {
    v1: Vec<Inner>,
    v2: Vec<Inner>,
}

#[derive(Serialize)]
struct Inner {}

fn main() {
    let outer = Outer {
        v1: vec![Inner {}],
        v2: vec![],
    };
    println!("{}", toml::to_string(&outer).unwrap());
}

If I add option to them, it would be work.

#[derive(Serialize)]
struct Outer {
    v1: Option<Vec<Inner>>,
    v2: Option<Vec<Inner>>,
}

But it seems a little complicated. Are there other solutions for it?

z-Wind avatar Oct 06 '22 12:10 z-Wind