Skip to content
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
@badicsalex

Description

@badicsalex

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?

Activity

dtolnay

dtolnay commented on Sep 2, 2022

@dtolnay
Owner

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

badicsalex commented on Sep 2, 2022

@badicsalex
Author

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:

    - identifier: '13'
      children:
      - identifier: '1'
        body: A nukleáris létesítménnyel összefüggő hatósági engedélyezési
          eljárás során biztosítani kell a szakértőként eljáró személyek
          vagy szervezetek függetlenségét. Az egyes eljárásokban kirendelt,
          ...

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.

badicsalex

badicsalex commented on Sep 2, 2022

@badicsalex
Author

Thanks for the very quick fix :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @dtolnay@badicsalex

      Issue actions

        Publish some libyaml settings to Serializer · Issue #321 · dtolnay/serde-yaml