From 4bbc95b219ba7ab966e55624d9c9e348a14c3b34 Mon Sep 17 00:00:00 2001 From: Duncan Holm Date: Mon, 11 Jul 2022 09:16:28 +0100 Subject: [PATCH] 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 --- lib/std/fmt.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index f6b98be44d..18e4a542b6 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -32,9 +32,11 @@ pub const FormatOptions = struct { /// this format: /// `{[argument][specifier]:[fill][alignment][width].[precision]}` /// -/// Each word between `[` and `]` is a parameter you have to replace with something: +/// Above, each word including its surrounding [ and ] is a parameter which you have to replace with something: /// -/// - *argument* is either the index or the name of the argument that should be inserted +/// - *argument* is either the numeric index or the field name of the argument that should be inserted +/// - when using a field name, you are required to enclose the field name (an identifier) in square +/// brackets, e.g. {[score]...} as opposed to the numeric index form which can be written e.g. {2...} /// - *specifier* is a type-dependent formatting option that determines how a type should formatted (see below) /// - *fill* is a single character which is used to pad the formatted text /// - *alignment* is one of the three characters `<`, `^` or `>`. they define if the text is *left*, *center*, or *right* aligned