-
Notifications
You must be signed in to change notification settings - Fork 189
How to serialize to inline table vs. dotted table? #265
Comments
Currently this crate unfortunately doesn't support a lot of control over serialization and formatting, it just guarantees it emits some valid toml document, but not necessarily the prettiest |
Support for serializing inline tables would be great, because I suspect that is why I'm getting a
This should serialize to something like:
But becomes invalid TOML if not using inline table format:
The solution would be either supporting inline tables or using extra logic to ensure all literal types under a table are written out before any nested table types. |
I just got hit by that I'm parsing perfectly valid toml and then can't write it out and thats no fun. |
Just for reference, cargo-edit uses toml_edit for parsing and writing cargo.toml files. Could be useful to see how they do it for anyone planning on implementing this for toml-rs. |
I'm definitely on team "would love to have an inline table serialization option!" here :) |
👍 Hitting this issue with |
because of `toml-rs` issue toml-rs/toml-rs#265
There's a round-trip test of an inline table at https://github.com/alexcrichton/toml-rs/blob/60b874308e6792a73cc00517a60bbef60a12e3cc/test-suite/tests/valid/example-v0.4.0.toml#L34-L46= which makes me think this must be possible somehow with the right structures. Maybe it only works with the toml-rs internal types at the moment and not with types defined outside the toml-rs library. |
Maintenance of this crate has moved to the https://github.com/toml-rs/toml repo. As a heads up, we plan to move Closing this out. If this is still a problem, feel free to recreate this issue in the new repo. |
It seems that nested Tables are always serialized to dotted tables. e.g.:
Even though the input string is an inline table, the output string uses a dotted table.
Is there no way to specify inline table when serializing?
The text was updated successfully, but these errors were encountered: