View source code
Display the source code in std/format.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Function std.format.singleSpec
Helper function that returns a FormatSpec
for a single specifier given
in fmt
.
Parameters
Name | Description |
---|---|
fmt | A format specifier. |
Returns
A FormatSpec
with the specifier parsed.
Throws
A FormatException
when more than one specifier is given or the specifier
is malformed.
Example
import std .exception : assertThrown;
auto spec = singleSpec("%2.3e");
writeln(spec .trailing); // ""
writeln(spec .spec); // 'e'
writeln(spec .width); // 2
writeln(spec .precision); // 3
assertThrown!FormatException(singleSpec(""));
assertThrown!FormatException(singleSpec("2.3e"));
assertThrown!FormatException(singleSpec("%2.3eTest"));
Authors
Walter Bright, Andrei Alexandrescu, and Kenji Hara
License
Copyright © 1999-2018 by the D Language Foundation | Page generated by ddox.