Adapt imports of std.format to new structure of std.format.

This commit is contained in:
berni44 2021-03-19 12:12:34 +01:00 committed by The Dlang Bot
parent 309b72f915
commit 6f2a0934a7
25 changed files with 79 additions and 70 deletions

View file

@ -1806,7 +1806,7 @@ if (isSomeString!S)
@safe unittest
{
import std.conv : to;
import std.format;
import std.format : format;
import std.typecons;
static auto makeEntry(S)(string l, string[] r)
@ -3613,7 +3613,7 @@ if (isDynamicArray!A)
*/
string toString()() const
{
import std.format : singleSpec;
import std.format.spec : singleSpec;
auto app = appender!string();
auto spec = singleSpec("%s");
@ -3634,7 +3634,7 @@ if (isDynamicArray!A)
return app.data;
}
import std.format : FormatSpec;
import std.format.spec : FormatSpec;
/// ditto
template toString(Writer)
@ -3642,7 +3642,7 @@ if (isDynamicArray!A)
{
void toString(ref Writer w, scope const ref FormatSpec!char fmt) const
{
import std.format : formatValue;
import std.format.write : formatValue;
import std.range.primitives : put;
put(w, Unqual!(typeof(this)).stringof);
put(w, '(');
@ -3670,7 +3670,8 @@ if (isDynamicArray!A)
@safe pure unittest
{
import std.format : format, singleSpec;
import std.format : format;
import std.format.spec : singleSpec;
auto app = appender!(int[])();
app.put(1);

View file

@ -27,7 +27,8 @@ module std.bigint;
import std.conv : ConvException;
import std.format : FormatSpec, FormatException;
import std.format.spec : FormatSpec;
import std.format : FormatException;
import std.internal.math.biguintcore;
import std.internal.math.biguintnoasm : BigDigit;
import std.range.primitives;
@ -1366,7 +1367,7 @@ public:
// the function failed to instantiate.
@system unittest
{
import std.format : FormatSpec;
import std.format.spec : FormatSpec;
import std.array : appender;
BigInt num = 503;
auto dst = appender!string();
@ -1746,7 +1747,7 @@ unittest
@safe unittest
{
import std.array;
import std.format;
import std.format.write : formattedWrite;
immutable string[][] table = [
/* fmt, +10 -10 */
@ -1797,7 +1798,7 @@ unittest
@safe unittest
{
import std.array;
import std.format;
import std.format.write : formattedWrite;
immutable string[][] table = [
/* fmt, +10 -10 */
@ -1848,7 +1849,7 @@ unittest
@safe unittest
{
import std.array;
import std.format;
import std.format.write : formattedWrite;
immutable string[][] table = [
/* fmt, +10 -10 */
@ -1900,7 +1901,7 @@ unittest
@safe unittest
{
import std.array;
import std.format;
import std.format.write : formattedWrite;
auto w1 = appender!string();
auto w2 = appender!string();

View file

@ -966,7 +966,7 @@ struct BitArray
private:
import core.bitop : btc, bts, btr, bsf, bt;
import std.format : FormatSpec;
import std.format.spec : FormatSpec;
size_t _len;
size_t* _ptr;

View file

@ -108,7 +108,7 @@ if (is(R : double) && is(I : double))
struct Complex(T)
if (isFloatingPoint!T)
{
import std.format : FormatSpec;
import std.format.spec : FormatSpec;
import std.range.primitives : isOutputRange;
/** The real part of the number. */
@ -158,7 +158,7 @@ if (isFloatingPoint!T)
void toString(Writer, Char)(scope Writer w, scope const ref FormatSpec!Char formatSpec) const
if (isOutputRange!(Writer, const(Char)[]))
{
import std.format : formatValue;
import std.format.write : formatValue;
import std.math : signbit;
import std.range.primitives : put;
formatValue(w, re, formatSpec);
@ -1124,7 +1124,7 @@ Complex!T sqrt(T)(Complex!T z) @safe pure nothrow @nogc
@safe unittest
{
// Test wide string formatting
import std.format;
import std.format.write : formattedWrite;
wstring wformat(T)(string format, Complex!T c)
{
import std.array : appender;

View file

@ -344,7 +344,7 @@ public:
*/
void toString(scope void delegate(const(char)[]) sink)
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
formattedWrite(sink, "Tid(%x)", cast(void*) mbox);
}

View file

@ -145,7 +145,8 @@ private
else
{
import std.array : appender;
import std.format : FormatSpec, formatValue;
import std.format.spec : FormatSpec;
import std.format.write : formatValue;
auto w = appender!T();
FormatSpec!(ElementEncodingType!T) f;
@ -1038,7 +1039,8 @@ if (!(isImplicitlyConvertible!(S, T) &&
}
import std.array : appender;
import std.format : FormatSpec, formatValue;
import std.format.spec : FormatSpec;
import std.format.write : formatValue;
//Default case, delegate to format
//Note: we don't call toStr directly, to avoid duplicate work.
@ -1100,7 +1102,8 @@ if (!(isImplicitlyConvertible!(S, T) &&
!isInfinite!S && isExactSomeString!T && !isCopyable!S && !isStaticArray!S)
{
import std.array : appender;
import std.format : FormatSpec, formatValue;
import std.format.spec : FormatSpec;
import std.format.write : formatValue;
auto w = appender!T();
FormatSpec!(ElementEncodingType!T) f;

View file

@ -2890,7 +2890,7 @@ public:
void toISOString(W)(ref W writer) const
if (isOutputRange!(W, char))
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
_date.toISOString(writer);
formattedWrite!("T%02d%02d%02d")(
writer,
@ -2967,7 +2967,7 @@ public:
void toISOExtString(W)(ref W writer) const
if (isOutputRange!(W, char))
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
_date.toISOExtString(writer);
formattedWrite!("T%02d:%02d:%02d")(
writer,
@ -3043,7 +3043,7 @@ public:
void toSimpleString(W)(ref W writer) const
if (isOutputRange!(W, char))
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
_date.toSimpleString(writer);
formattedWrite!(" %02d:%02d:%02d")(
writer,
@ -7365,7 +7365,7 @@ public:
void toISOString(W)(ref W writer) const
if (isOutputRange!(W, char))
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
if (_year >= 0)
{
if (_year < 10_000)
@ -7449,7 +7449,7 @@ public:
void toISOExtString(W)(ref W writer) const
if (isOutputRange!(W, char))
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
if (_year >= 0)
{
if (_year < 10_000)
@ -7533,7 +7533,7 @@ public:
void toSimpleString(W)(ref W writer) const
if (isOutputRange!(W, char))
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
if (_year >= 0)
{
if (_year < 10_000)
@ -9064,7 +9064,7 @@ public:
void toISOString(W)(ref W writer) const
if (isOutputRange!(W, char))
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
formattedWrite(writer, "%02d%02d%02d", _hour, _minute, _second);
}
@ -9111,7 +9111,7 @@ public:
void toISOExtString(W)(ref W writer) const
if (isOutputRange!(W, char))
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
formattedWrite(writer, "%02d:%02d:%02d", _hour, _minute, _second);
}

View file

@ -1420,7 +1420,7 @@ package:
{
import std.datetime.date : DateTimeException;
import std.exception : enforce;
import std.format : formattedWrite;
import std.format.write : formattedWrite;
immutable absOffset = abs(utcOffset);
enforce!DateTimeException(absOffset < dur!"minutes"(1440),
"Offset from UTC must be within range (-24:00 - 24:00).");
@ -1489,7 +1489,7 @@ package:
static void toISOExtString(W)(ref W writer, Duration utcOffset)
{
import std.datetime.date : DateTimeException;
import std.format : formattedWrite;
import std.format.write : formattedWrite;
import std.exception : enforce;
immutable absOffset = abs(utcOffset);

View file

@ -168,7 +168,7 @@ The fractional second part is in milliseconds and is always 3 digits.
void systimeToISOString(OutputRange)(OutputRange o, const ref SysTime time)
if (isOutputRange!(OutputRange,string))
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
const auto dt = cast(DateTime) time;
const auto fsec = time.fracSecs.total!"msecs";
@ -657,7 +657,7 @@ private struct MsgRange
private void formatString(A...)(MsgRange oRange, A args)
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
foreach (arg; args)
{
@ -1043,7 +1043,7 @@ abstract class Logger
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
synchronized (mutex)
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
if (isLoggingEnabled(ll, this.logLevel_, globalLogLevel,
condition))
@ -1091,7 +1091,7 @@ abstract class Logger
static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
synchronized (mutex)
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
if (isLoggingEnabled(ll, this.logLevel_, globalLogLevel))
{
@ -1444,7 +1444,7 @@ abstract class Logger
{
static if (isLoggingActive) synchronized (mutex)
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
if (isLoggingEnabled(ll, this.logLevel_, globalLogLevel, condition))
{
@ -1492,7 +1492,7 @@ abstract class Logger
{
static if (isLoggingActive) synchronized (mutex)
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
if (isLoggingEnabled(ll, this.logLevel_, globalLogLevel))
{
@ -1541,7 +1541,7 @@ abstract class Logger
{
static if (isLoggingActive) synchronized (mutex)
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
if (isLoggingEnabled(this.logLevel_, this.logLevel_, globalLogLevel,
condition))
@ -1587,7 +1587,7 @@ abstract class Logger
{
static if (isLoggingActive) synchronized (mutex)
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
if (isLoggingEnabled(this.logLevel_, this.logLevel_,
globalLogLevel))

View file

@ -21,7 +21,7 @@ class FileLogger : Logger
{
import std.concurrency : Tid;
import std.datetime.systime : SysTime;
import std.format : formattedWrite;
import std.format.write : formattedWrite;
/** A constructor for the `FileLogger` Logger.

View file

@ -5211,7 +5211,7 @@ slurp(Types...)(string filename, scope const(char)[] format)
import std.array : appender;
import std.conv : text;
import std.exception : enforce;
import std.format : formattedRead;
import std.format.read : formattedRead;
import std.stdio : File;
import std.string : stripRight;

View file

@ -1667,7 +1667,7 @@ Params:
void defaultGetoptFormatter(Output)(Output output, string text, Option[] opt, string style = "%*s %*s%*s%s\n")
{
import std.algorithm.comparison : min, max;
import std.format : formattedWrite;
import std.format.write : formattedWrite;
output.formattedWrite("%s\n", text);

View file

@ -1726,7 +1726,7 @@ if (isOutputRange!(Out,char))
// https://issues.dlang.org/show_bug.cgi?id=20511
@system unittest
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
import std.range : nullSink, outputRangeObject;
outputRangeObject!(const(char)[])(nullSink)
@ -2325,7 +2325,7 @@ pure nothrow @safe unittest
@safe unittest
{
import std.array : appender;
import std.format : formattedWrite;
import std.format.write : formattedWrite;
string s =
`{

View file

@ -605,7 +605,8 @@ public:
/// ditto
template toString()
{
import std.format : FormatSpec, formatValue;
import std.format.spec : FormatSpec;
import std.format.write : formatValue;
// Needs to be a template because of https://issues.dlang.org/show_bug.cgi?id=13737.
void toString()(scope void delegate(const(char)[]) sink, scope const ref FormatSpec!char fmt)
{

View file

@ -311,7 +311,7 @@ class OutBuffer
*/
void writef(Char, A...)(scope const(Char)[] fmt, A args)
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
formattedWrite(this, fmt, args);
}
@ -337,7 +337,7 @@ class OutBuffer
*/
void writefln(Char, A...)(scope const(Char)[] fmt, A args)
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
formattedWrite(this, fmt, args);
put('\n');
}

View file

@ -814,7 +814,7 @@ pure @safe unittest
// https://issues.dlang.org/show_bug.cgi?id=10571
@safe unittest
{
import std.format;
import std.format.write : formattedWrite;
string buf;
formattedWrite((scope const(char)[] s) { buf ~= s; }, "%s", "hello");
assert(buf == "hello");
@ -822,7 +822,7 @@ pure @safe unittest
@safe unittest
{
import std.format;
import std.format.write : formattedWrite;
import std.meta : AliasSeq;
struct PutC(C)
{

View file

@ -13,7 +13,7 @@ module std.regex.internal.generator;
@trusted private struct SampleGenerator(Char)
{
import std.array : appender, Appender;
import std.format : formattedWrite;
import std.format.write : formattedWrite;
import std.random : Xorshift;
import std.regex.internal.ir : Regex, IR, IRL;
import std.utf : isValidDchar, byChar;

View file

@ -376,7 +376,7 @@ struct Group(DataIndex)
if (begin < end)
return "(unmatched)";
import std.array : appender;
import std.format : formattedWrite;
import std.format.write : formattedWrite;
auto a = appender!string();
formattedWrite(a, "%s..%s", begin, end);
return a.data;
@ -387,7 +387,7 @@ struct Group(DataIndex)
@trusted string disassemble(in Bytecode[] irb, uint pc, in NamedGroup[] dict=[])
{
import std.array : appender;
import std.format : formattedWrite;
import std.format.write : formattedWrite;
auto output = appender!string();
formattedWrite(output,"%s", irb[pc].mnemonic);
switch (irb[pc].code)

View file

@ -1011,7 +1011,7 @@ if (isForwardRange!R && is(ElementType!R : dchar))
@trusted void error(string msg)
{
import std.array : appender;
import std.format : formattedWrite;
import std.format.write : formattedWrite;
auto app = appender!string();
formattedWrite(app, "%s\nPattern with error: `%s` <--HERE-- `%s`",
msg, origin[0..$-pat.length], pat);

View file

@ -312,7 +312,7 @@ public:
{
import std.conv : text;
import std.exception : enforce;
import std.format : formattedRead;
import std.format.read : formattedRead;
import std.string : chomp;
enforce(file.isOpen, "ByRecord: File must be open");
@ -1586,7 +1586,7 @@ Throws: `Exception` if the file is not opened.
alias A = typeof(arg);
static if (isAggregateType!A || is(A == enum))
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
formattedWrite(w, "%s", arg);
}
@ -1610,7 +1610,7 @@ Throws: `Exception` if the file is not opened.
}
else
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
// Most general case
formattedWrite(w, "%s", arg);
@ -1663,7 +1663,7 @@ Throws: `Exception` if the file is not opened.
/// ditto
void writef(Char, A...)(in Char[] fmt, A args)
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
formattedWrite(lockingTextWriter(), fmt, args);
}
@ -1682,7 +1682,7 @@ Throws: `Exception` if the file is not opened.
/// ditto
void writefln(Char, A...)(in Char[] fmt, A args)
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
auto w = lockingTextWriter();
formattedWrite(w, fmt, args);
@ -2028,7 +2028,7 @@ $(CONSOLE
/// ditto
uint readf(Data...)(scope const(char)[] format, auto ref Data data)
{
import std.format : formattedRead;
import std.format.read : formattedRead;
assert(isOpen);
auto input = LockingTextReader(this);

View file

@ -203,7 +203,7 @@ version (D_BetterC) {} else
// Return a "pretty-printed" representation of expr
string pprint(Expr expr)
{
import std.format;
import std.format : format;
return expr.match!(
(double num) => "%g".format(num),
@ -223,7 +223,7 @@ version (D_BetterC) {} else
assert(pprint(*myExpr) == "(a + (2 * b))");
}
import std.format : FormatSpec, singleSpec;
import std.format.spec : FormatSpec, singleSpec;
import std.meta : AliasSeq, Filter, IndexOf = staticIndexOf, Map = staticMap;
import std.meta : NoDuplicates;
import std.meta : anySatisfy, allSatisfy;
@ -758,7 +758,7 @@ public:
*/
void toString(this This, Sink, Char)(ref Sink sink, const ref FormatSpec!Char fmt)
{
import std.format : formatValue;
import std.format.write : formatValue;
this.match!((ref value) {
formatValue(sink, value, fmt);

View file

@ -69,7 +69,8 @@ Authors: $(HTTP erdani.org, Andrei Alexandrescu),
*/
module std.typecons;
import std.format : singleSpec, FormatSpec, formatValue;
import std.format.spec : singleSpec, FormatSpec;
import std.format.write : formatValue;
import std.meta : AliasSeq, allSatisfy;
import std.range.primitives : isOutputRange;
import std.traits;
@ -1268,7 +1269,7 @@ if (distinctFieldNames!(Specs))
return app.data;
}
import std.format : FormatSpec;
import std.format.spec : FormatSpec;
/**
* Formats `Tuple` with either `%s`, `%(inner%)` or `%(inner%|sep%)`.
@ -2945,7 +2946,7 @@ struct Nullable(T)
@safe unittest
{
import std.array : appender;
import std.format : formattedWrite;
import std.format.write : formattedWrite;
auto app = appender!string();
Nullable!int a = 1;
@ -3617,7 +3618,8 @@ Params:
template toString()
{
import std.format : FormatSpec, formatValue;
import std.format.spec : FormatSpec;
import std.format.write : formatValue;
// Needs to be a template because of https://issues.dlang.org/show_bug.cgi?id=13737.
void toString()(scope void delegate(const(char)[]) sink, scope const ref FormatSpec!char fmt)
{
@ -4126,7 +4128,8 @@ Params:
template toString()
{
import std.format : FormatSpec, formatValue;
import std.format.spec : FormatSpec;
import std.format.write : formatValue;
// Needs to be a template because of https://issues.dlang.org/show_bug.cgi?id=13737.
void toString()(scope void delegate(const(char)[]) sink, scope const ref FormatSpec!char fmt)
{

View file

@ -960,7 +960,7 @@ struct MultiArray(Types...)
void store(OutRange)(scope OutRange sink) const
if (isOutputRange!(OutRange, char))
{
import std.format : formattedWrite;
import std.format.write : formattedWrite;
formattedWrite(sink, "[%( 0x%x, %)]", offsets[]);
formattedWrite(sink, ", [%( 0x%x, %)]", sz[]);
formattedWrite(sink, ", [%( 0x%x, %)]", storage);
@ -2431,7 +2431,7 @@ public:
---
*/
private import std.format : FormatSpec;
private import std.format.spec : FormatSpec;
/***************************************
* Obtain a textual representation of this InversionList
@ -2444,7 +2444,7 @@ public:
*/
void toString(Writer)(scope Writer sink, scope const ref FormatSpec!char fmt) /* const */
{
import std.format : formatValue;
import std.format.write : formatValue;
auto range = byInterval;
if (range.empty)
return;

View file

@ -412,7 +412,7 @@ package string urlEncode(scope string[string] values) @safe pure
return "";
import std.array : Appender;
import std.format : formattedWrite;
import std.format.write : formattedWrite;
Appender!string enc;
enc.reserve(values.length * 128);

View file

@ -68,7 +68,7 @@ version (Windows):
import core.sys.windows.winbase, core.sys.windows.winnt;
import std.array : appender;
import std.conv : to;
import std.format : formattedWrite;
import std.format.write : formattedWrite;
import std.windows.charset;
string sysErrorString(