Add quoted_strings to FormatOptions
#9221
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rationale for this change
In some cases, it is desirable to print strings with surrounding quotation marks. A typical example that we run into in https://github.com/rerun-io/rerun is a
StructArraythat contains empty strings:Current formatting:
Added option in this PR:
What changes are included in this PR?
This PR relies on
std::fmt::Debugto do the actual formatting of strings, which means that all escaping is handled out of the box.Are these changes tested?
This PR contains test for different types of inputs, including escape sequences. Additionally, it also tests the
StructArrayexample outlined above.Are there any user-facing changes?
By default this option is false, making the feature opt-in.