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

Support parsing duplicate sections to Vec<T> #19

Open
Zerowalker opened this issue Nov 25, 2021 · 5 comments
Open

Support parsing duplicate sections to Vec<T> #19

Zerowalker opened this issue Nov 25, 2021 · 5 comments

Comments

@Zerowalker
Copy link

Zerowalker commented Nov 25, 2021

As far as i can tell it's not supported.

Here's an example:

struct User{
    #[serde(rename = "Name")]
    name: String,
}

struct Users{
    #[serde(rename = "User")]
    user: Vec<User>,
};

let raw = r#"
[User]
Name=Foo
[User]
Name=Bar
"#;
// Not supported cause of Vec, but not using Vec makes it fail (accurately) cause of duplicate sections
let data: Users = serde_ini::from_str(&raw).unwrap();
@arcnmx
Copy link
Owner

arcnmx commented Nov 25, 2021

fwiw master currently has a similar example that deserializes to a top-level Vec, but the feature is incomplete and unreleased.

@Zerowalker
Copy link
Author

Ah indeed it does, so this was a bit unnecessary of me bringing it up i guess;P

@arcnmx
Copy link
Owner

arcnmx commented Nov 26, 2021

Even so, it seems reasonable to expect your example to work. This is also related to allowing duplicate keys to be {de,}serialized as a vec.

@Zerowalker
Copy link
Author

But the feature was incomplete right?
so if the example you linked doesn't work, it make sense my doesn't work, or did i misunderstand you?

@arcnmx
Copy link
Owner

arcnmx commented Nov 27, 2021

But the feature was incomplete right?

The example in master is incomplete because it can only deserialize. Serialization fails because it is not implemented.

so if the example you linked doesn't work, it make sense my doesn't work

The example linked does work, but its approach differs from yours (uses a top-level vec of an enum instead of a top-level map with a vec field). I'm pretty sure your code still does not work.

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

2 participants