This repository was archived by the owner on Mar 25, 2024. It is now read-only.
This repository was archived by the owner on Mar 25, 2024. It is now read-only.
Publish some libyaml settings to Serializer #321
Closed
Description
I'd like to alter the formatting of my yml output files, most importantly the width of the output.
I think this could be done by exposing yaml_emitter_set_width from the Emitter, and then on the Serializer structure, so that I could do something like:
let mut ser = serde_yaml::Serializer::new(&mut buffer);
ser.set_width(-1);
my_data.serialize(&mut ser)?;
Would you accept a PR implementing something like this?
Metadata
Metadata
Assignees
Labels
No labels
Activity
dtolnay commentedon Sep 2, 2022
Could you give an example of a document where serializing with width=-1 makes a difference? It's possible that should just be default for all serializers.
badicsalex commentedon Sep 2, 2022
My preferred format:
https://github.com/badicsalex/hun_law_rs/blob/master/tests/datatests/data_convert_block_amendments/complex_1.yml#L38
This is how that part serializes since 0.9:
There are no line breaks in my long strings.
width=-1 could be the default for sure, since that's how it worked up until 0.8 and I didn't see any complaints.
It seems like a taste thing though, because the line-broken version is generally easier to read, while in my case I usually don't care much about the actual content and gladly let it fall off the right side of the screen. Not line-breaking the strings also makes diffs cleaner.
serialization: test long strings and update serde_yaml
badicsalex commentedon Sep 2, 2022
Thanks for the very quick fix :)