mirror of
https://github.com/yamadapc/d-colorize
synced 2024-11-14 21:14:00 +01:00
Fix a bunch of bugs in the cwrite
module.
We had problems with format parameters dispatching (`cwritefln` ended up calling `format` with '\n' as a trailing - orphan - format parameter), `format` not being imported from `std.string` and an infinitely recursive template case for the overloaded `cwritef` function. This also bumps the version to 0.2.1.
This commit is contained in:
parent
0a762e92ab
commit
7398ee11f1
|
@ -17,15 +17,15 @@ void cwrite(T...)(T args) if (!is(T[0] : File))
|
|||
}
|
||||
|
||||
/// Coloured writef.
|
||||
void cwritef(T...)(T args)
|
||||
void cwritef(Char, T...)(in Char[] fmt, T args) if (!is(T[0] : File))
|
||||
{
|
||||
stdout.cwritef(args);
|
||||
stdout.cwritef(fmt, args);
|
||||
}
|
||||
|
||||
/// Coloured writefln.
|
||||
void cwritefln(T...)(T args)
|
||||
void cwritefln(Char, T...)(in Char[] fmt, T args)
|
||||
{
|
||||
stdout.cwritef(args, "\n");
|
||||
stdout.cwritef(fmt ~ "\n", args);
|
||||
}
|
||||
|
||||
/// Coloured writeln.
|
||||
|
@ -38,6 +38,7 @@ void cwriteln(T...)(T args)
|
|||
/// Coloured writef to a File.
|
||||
void cwritef(Char, A...)(File f, in Char[] fmt, A args)
|
||||
{
|
||||
import std.string : format;
|
||||
auto s = format(fmt, args);
|
||||
f.cwrite(s);
|
||||
}
|
||||
|
@ -71,3 +72,4 @@ void cwrite(S...)(File f, S args)
|
|||
f.write(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue