authorgravatar for duncan@holm.scotDuncan Holm <duncan@holm.scot> 2022-07-11 09:16:28+01:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-07-11 11:16:28+03:00
log4bbc95b219ba7ab966e55624d9c9e348a14c3b34
tree317d643bf3ad8061b6795619869c13ce0af244a8
parent76c89a3de9661264395d111fa3db8d4cfa633f83
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

std.fmt: clarify the description of placeholders in Format Strings

Those 6 sets of square brackets are just a typographical aid used in this doc-comment, and must not actually be written by the user in their own format string... except for in one case where they must * Avoid the implication that the numeric index is 1-based rather than 0-based

1 files changed, 4 insertions(+), 2 deletions(-)

lib/std/fmt.zig+4-2
......@@ -32,9 +32,11 @@ pub const FormatOptions = struct {
3232/// this format:
3333/// `{[argument][specifier]:[fill][alignment][width].[precision]}`
3434///
35/// Each word between `[` and `]` is a parameter you have to replace with something:
35/// Above, each word including its surrounding [ and ] is a parameter which you have to replace with something:
3636///
37/// - *argument* is either the index or the name of the argument that should be inserted
37/// - *argument* is either the numeric index or the field name of the argument that should be inserted
38/// - when using a field name, you are required to enclose the field name (an identifier) in square
39/// brackets, e.g. {[score]...} as opposed to the numeric index form which can be written e.g. {2...}
3840/// - *specifier* is a type-dependent formatting option that determines how a type should formatted (see below)
3941/// - *fill* is a single character which is used to pad the formatted text
4042/// - *alignment* is one of the three characters `<`, `^` or `>`. they define if the text is *left*, *center*, or *right* aligned