singleSpec

Helper function that returns a FormatSpec for a single specifier given in fmt.

singleSpec
(
Char
)
(
Char[] fmt
)

Parameters

fmt Char[]

A format specifier.

Return Value

Type: FormatSpec!Char

A FormatSpec with the specifier parsed.

Throws

A FormatException when more than one specifier is given or the specifier is malformed.

Examples

import std.exception : assertThrown;
auto spec = singleSpec("%2.3e");

assert(spec.trailing == "");
assert(spec.spec == 'e');
assert(spec.width == 2);
assert(spec.precision == 3);

assertThrown!FormatException(singleSpec(""));
assertThrown!FormatException(singleSpec("2.3e"));
assertThrown!FormatException(singleSpec("%2.3eTest"));

Meta

Suggestion Box / Bug Report