WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@eddyb
Copy link
Member

@eddyb eddyb commented Aug 16, 2025

At some point I added a multiline pretty string format using Rust-compatible string continuations, i.e. \ at the end of a line ignores all whitespace following it, so these are equivalent Rust literals:

"foo\
         \n"
"foo\n"
"foo
"

(the last one is never used by spirt::pretty, because it cannot be indented without changing the meaning of the string literal, and spirt::print::pretty assumes everything can be indented)

This PR ignores trailing \n when determining whether the multiline format should be used, i.e. only \n in the middle of a string will use \ continuations (with the \n moved to the start of following lines).


Quick example (the very one that made me think it'd be worth a minor aesthetic improvement):

Before After
image image

@eddyb eddyb requested a review from a team August 16, 2025 19:20
@LegNeato LegNeato added this pull request to the merge queue Aug 16, 2025
Merged via the queue into Rust-GPU:main with commit e8757ad Aug 16, 2025
6 checks passed
@eddyb eddyb deleted the print-str-trailing-nl branch August 18, 2025 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants