singleSpec

Helper function that returns a FormatSpec for a single format specifier.

singleSpec
(
Char
)
(
Char[] fmt
)

Parameters

fmt Char[]

a format string containing a single format specifier

Char

character type of fmt

Return Value

Type: FormatSpec!Char

A FormatSpec with the format specifier parsed.

Throws

A FormatException when the format string contains no format specifier or more than a single format specifier or when the format specifier is malformed.

Examples

import std.array : appender;
import std.format.write : formatValue;

auto spec = singleSpec("%10.3e");
auto writer = appender!string();
writer.formatValue(42.0, spec);

assert(writer.data == " 4.200e+01");

Meta