Skip to content

Add a way to customize the literal-ness (single/double quotes) of a string #590

Open
@sunshowers

Description

@sunshowers

Hi everyone (and epage in particular), thanks for all your hard work on toml! Really appreciating all the work y'all have done integrating toml_edit and toml.

For guppy, tried upgrading toml to 0.7 and sadly ran into a deal-breaking issue. Guppy currently produces output that has single quotes in it, e.g. this file. When I migrate to toml 0.7, it becomes double-quoted as seen in https://gist.github.com/sunshowers/0ed4ab2143ea1efa8afb10f1a500e61e#file-gistfile0-txt-L4-L28.

The output format cannot be changed for backwards compatibility reasons -- these files are checked into repositories and one of the promises made by hakari is to not change how checked-in files are recorded.

So it seems like what I would need is a way to change how strings are recorded so that they're presented as single quotes.

I spent some time looking around and it looks like while this is supported internally, there's no API to access this. Value::String is a Formatted<String>, which doesn't seem to be high-enough fidelity. It seems like what we would really need is a StringWithQuotes or similar, which would track both the string as well as the quoting style.

What do you think? Without this, or some other solution, I'll have to be stuck at toml 0.5 forever. This would be a shame :(

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-editArea: TOML editing APIC-enhancementCategory: Raise on the bar on expectations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions