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@0.5.7 will sometimes fail to serialize #446

Closed

Conversation

johnsonw
Copy link

@johnsonw johnsonw commented Feb 21, 2024

Toml@0.5.7 will sometimes fail and produce the following error with a structure that can
be converted into valid toml:

Result::unwrap() on an Err value: ValueAfterTable

The crate can correctly serialize such objects in version 0.8.1.

Example:

 #[derive(serde::Serialize)]
  pub struct MyObjectTest {
      pub obj: MyObject,
  }

  #[derive(serde::Serialize)]
  pub struct Boat {
      pub length: i32,
      pub has_motor: bool,
  }

  #[derive(serde::Serialize)]
  pub struct MyObject {
      pub name: String,
      pub boat: Option<Boat>,
      pub registered: bool,
  }

  let obj = MyObject {
      name: "Frosty".to_string(),
      boat: Some(Boat {
          length: 21,
          has_motor: true,
      }),
      registered: true,
  };

Serializing this struct with toml@0.5.7 will result in:

`Result::unwrap()` on an `Err` value: ValueAfterTable

After updating toml to 0.8.1, the same structure will serialize to:

name = "Frosty"
registered = true

[boat]
length = 21
has_motor = true

…e that can

be converted into valid toml:

```
Result::unwrap() on an Err value: ValueAfterTable
```

The crate can correctly serialize such objects in version 0.8.1.

Signed-off-by: William Johnson <wjohnson@whamcloud.com>
  toml@0.5.7.

Signed-off-by: William Johnson <wjohnson@whamcloud.com>
@ilyagr
Copy link

ilyagr commented Feb 23, 2024

This might also be related to #439.

@mitsuhiko
Copy link
Owner

Closing this as a duplicate of #439

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

Successfully merging this pull request may close these issues.

None yet

3 participants