Skip to content

Commit 1924e9b

Browse files
committed
Add note about long format strings
1 parent b02ff8f commit 1924e9b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

modules/contributor/pages/code-style-guide.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,12 @@ enum Error {
314314
=== Named versus unnamed format string identifiers
315315

316316
For simple string formatting (up to two substitutions), we allow unnamed (and thus also uncaptured) identifiers.
317+
317318
For more complex formatting (more than two substitutions), we require named identifiers to avoid ambiguity, and to decouple argument order from the text (which can lead to incorrect text when the wording is changed and `{}` are reordered while the arguments aren't).
319+
This rule needs to strike a balance between explicitness and concise `format!()` invocations.
320+
Long `format!()` expressions can lead to rustfmt breakage.
321+
It might be better to split up long formatting strings into multiple smaller ones.
322+
318323
Mix-and-matching of named versus unnamed identifiers must be avoided.
319324
See the next section about captured versus uncaptured identifiers.
320325

0 commit comments

Comments
 (0)