summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2017-12-03 19:53:06 +0100
committerEugen Wissner <belka@caraus.de>2017-12-03 19:53:06 +0100
commit26c3532e282f549f5634f131f042c4c13349e69b (patch)
tree6bdba031c892c84750ed9648243d451a3c7e2546
parent75ce854192385788fdd18d1ee9109f73b69273e1 (diff)
downloadtanya-26c3532e282f549f5634f131f042c4c13349e69b.tar.gz
Wrap formatting into printToString
printToString gets the output string as argument and can be called recursive with the same output string to format ranges.
-rw-r--r--source/tanya/format/package.d11
1 files changed, 8 insertions, 3 deletions
diff --git a/source/tanya/format/package.d b/source/tanya/format/package.d
index d542529..e283c3d 100644
--- a/source/tanya/format/package.d
+++ b/source/tanya/format/package.d
@@ -505,10 +505,9 @@ if (T.sizeof == U.sizeof)
copy((&src)[0 .. 1], (&dest)[0 .. 1]);
}
-package(tanya) String format(string fmt, Args...)(auto ref Args args)
+private ref String printToString(string fmt, Args...)(return ref String result,
+ auto ref Args args)
{
- String result;
-
static if (is(Unqual!(Args[0]) == typeof(null)))
{
result.insertBack("null");
@@ -758,6 +757,12 @@ ParamEnd:
return result;
}
+package(tanya) String format(string fmt, Args...)(auto ref Args args)
+{
+ String formatted;
+ return printToString!fmt(formatted, args);
+}
+
// One argument tests.
@nogc pure @safe unittest
{