Skip to content

Commit fe0a6b7

Browse files
committed
examples
1 parent c3c38f4 commit fe0a6b7

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Diff for: doc/syntax.rst

+9-2
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ Format specifications for range types have the following syntax:
493493
.. productionlist:: sf
494494
range_format_spec: [":" [`n`][`range_type`][`range_underlying_spec`]]
495495

496-
The `n` option causes the range to be formatted without the opening and closing brackets.
496+
The `n` option formats the range without the opening and closing brackets.
497497

498498
The available presentation types for `range_type` are:
499499

@@ -509,7 +509,8 @@ The available presentation types for `range_type` are:
509509
| | |
510510
+---------+----------------------------------------------------------+
511511

512-
If `range_type` is `s` or `?s`, the underlying type of the range must be a char type.
512+
If `range_type` is `s` or `?s`, the underlying type of the range must be a character type. The
513+
`n` option and `range_underlying_spec` are mutually exclusive with `s` and `?s`.
513514

514515
The `underlying_spec` is parsed based on the formatter of the range's
515516
reference type.
@@ -526,6 +527,12 @@ Examples::
526527
// Result: [0xa, 0x14, 0x1e]
527528
fmt::format("{}", vector{'h', 'e', 'l', 'l', 'o'});
528529
// Result: ['h', 'e', 'l', 'l', 'o']
530+
fmt::format("{:n}", vector{'h', 'e', 'l', 'l', 'o'});
531+
// Result: 'h', 'e', 'l', 'l', 'o'
532+
fmt::format("{:s}", vector{'h', 'e', 'l', 'l', 'o'});
533+
// Result: "hello"
534+
fmt::format("{:?s}", vector{'h', 'e', 'l', 'l', 'o', '\n'});
535+
// Result: "hello\n"
529536
fmt::format("{::}", vector{'h', 'e', 'l', 'l', 'o'});
530537
// Result: [h, e, l, l, o]
531538
fmt::format("{::d}", vector{'h', 'e', 'l', 'l', 'o'});

0 commit comments

Comments
 (0)