mirror of
https://github.com/dlang/phobos.git
synced 2025-04-26 21:22:20 +03:00
clean scope imports
imports of `std.range, std.algorithm, std.array, std.string, std.format, std.uni` are affected.
This commit is contained in:
parent
b6698d0b0f
commit
c8d9afedea
16 changed files with 67 additions and 64 deletions
|
@ -409,7 +409,7 @@ private T* addressOf(T)(ref T val) { return &val; }
|
|||
private template algoFormat()
|
||||
{
|
||||
import std.format : format;
|
||||
alias algoFormat = std.string.format;
|
||||
alias algoFormat = format;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3119,7 +3119,7 @@ if (is(typeof(ElementType!Range.init == Separator.init))
|
|||
@safe unittest
|
||||
{
|
||||
import std.internal.test.dummyrange;
|
||||
import std.range;
|
||||
import std.algorithm;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
@ -3181,6 +3181,7 @@ if (is(typeof(ElementType!Range.init == Separator.init))
|
|||
}
|
||||
@safe unittest
|
||||
{
|
||||
import std.algorithm;
|
||||
import std.range;
|
||||
auto L = retro(iota(1L, 10L));
|
||||
auto s = splitter(L, 5L);
|
||||
|
@ -3658,14 +3659,14 @@ if (isSomeChar!C)
|
|||
{
|
||||
import std.uni : isWhite;
|
||||
|
||||
auto r = find!(std.uni.isWhite)(_s);
|
||||
auto r = find!(isWhite)(_s);
|
||||
_frontLength = _s.length - r.length;
|
||||
}
|
||||
|
||||
public:
|
||||
this(C[] s) pure @safe
|
||||
{
|
||||
import std.string;
|
||||
import std.string : strip;
|
||||
_s = s.strip();
|
||||
getFirst();
|
||||
}
|
||||
|
@ -3731,7 +3732,7 @@ if (isSomeChar!C)
|
|||
lines[1] = "line \ttwo".dup;
|
||||
lines[2] = "yah last line\ryah".dup;
|
||||
foreach (line; lines) {
|
||||
foreach (word; std.array.splitter(std.string.strip(line))) {
|
||||
foreach (word; splitter(strip(line))) {
|
||||
if (word in dictionary) continue; // Nothing to do
|
||||
auto newID = dictionary.length;
|
||||
dictionary[to!string(word)] = cast(uint)newID;
|
||||
|
@ -3748,7 +3749,7 @@ if (isSomeChar!C)
|
|||
@safe unittest
|
||||
{
|
||||
import std.conv : text;
|
||||
import std.string : split;
|
||||
import std.array : split;
|
||||
|
||||
// Check consistency:
|
||||
// All flavors of split should produce the same results
|
||||
|
@ -5624,7 +5625,7 @@ if (Ranges.length > 1 && is(typeof(startsWith!pred(haystack, needles))))
|
|||
|
||||
@safe unittest
|
||||
{
|
||||
import std.string : toUpper;
|
||||
import std.uni : toUpper;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
@ -10383,7 +10384,7 @@ unittest
|
|||
unittest
|
||||
{
|
||||
import std.random : Random, unpredictableSeed, uniform;
|
||||
import std.string : toUpper;
|
||||
import std.uni : toUpper;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
|
|
@ -1250,7 +1250,7 @@ if (isSomeString!S)
|
|||
unittest
|
||||
{
|
||||
import std.conv : to;
|
||||
import std.string;
|
||||
import std.format;
|
||||
import std.typecons;
|
||||
|
||||
static auto makeEntry(S)(string l, string[] r)
|
||||
|
@ -2702,7 +2702,7 @@ unittest{
|
|||
|
||||
unittest
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
auto app = appender!(int[])();
|
||||
app.put(1);
|
||||
app.put(2);
|
||||
|
|
|
@ -1570,7 +1570,7 @@ public:
|
|||
///
|
||||
unittest
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
|
||||
debug(bitarray) printf("BitArray.toString unittest\n");
|
||||
BitArray b;
|
||||
|
@ -1680,7 +1680,7 @@ public:
|
|||
|
||||
unittest
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
|
||||
BitArray b;
|
||||
|
||||
|
@ -3424,7 +3424,7 @@ unittest
|
|||
|
||||
unittest
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
import std.array;
|
||||
import std.typetuple;
|
||||
foreach(endianness; TypeTuple!(Endian.bigEndian, Endian.littleEndian))
|
||||
|
|
|
@ -141,7 +141,7 @@ struct Complex(T) if (isFloatingPoint!T)
|
|||
// Formatting with std.string.format specs: the precision and width
|
||||
// specifiers apply to both the real and imaginary parts of the
|
||||
// complex number.
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
assert(format("%.2f", c) == "1.20+3.40i");
|
||||
assert(format("%4.1f", c) == " 1.2+ 3.4i");
|
||||
}
|
||||
|
@ -866,7 +866,7 @@ unittest
|
|||
// Issue 10881: support %f formatting of complex numbers
|
||||
unittest
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
|
||||
auto x = complex(1.2, 3.4);
|
||||
assert(format("%.2f", x) == "1.20+3.40i");
|
||||
|
|
|
@ -1209,7 +1209,7 @@ public:
|
|||
void popFront()
|
||||
{
|
||||
static if (ErrorLevel == Malformed.throwException)
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
// Skip last of record when header is depleted.
|
||||
if (_popCount.ptr && _popCount.empty)
|
||||
while(!recordEnd())
|
||||
|
|
|
@ -496,7 +496,7 @@ private:
|
|||
+/
|
||||
struct SysTime
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
import std.typecons : Rebindable;
|
||||
|
||||
public:
|
||||
|
@ -8835,7 +8835,7 @@ private:
|
|||
+/
|
||||
struct Date
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -13079,7 +13079,7 @@ private:
|
|||
+/
|
||||
struct TimeOfDay
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -14294,7 +14294,7 @@ private:
|
|||
+/
|
||||
struct DateTime
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -17298,7 +17298,7 @@ private:
|
|||
+/
|
||||
struct Interval(TP)
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -20198,7 +20198,7 @@ unittest
|
|||
+/
|
||||
struct PosInfInterval(TP)
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -22385,7 +22385,7 @@ unittest
|
|||
+/
|
||||
struct NegInfInterval(TP)
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -25087,7 +25087,7 @@ unittest
|
|||
struct IntervalRange(TP, Direction dir)
|
||||
if(isTimePoint!TP && dir != Direction.both)
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -25585,7 +25585,7 @@ unittest
|
|||
struct PosInfIntervalRange(TP)
|
||||
if(isTimePoint!TP)
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -25873,7 +25873,7 @@ unittest
|
|||
struct NegInfIntervalRange(TP)
|
||||
if(isTimePoint!TP)
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -26136,7 +26136,7 @@ unittest
|
|||
+/
|
||||
abstract class TimeZone
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
public:
|
||||
|
||||
/++
|
||||
|
@ -26277,7 +26277,7 @@ auto tz = TimeZone.getTimeZone("America/Los_Angeles");
|
|||
return PosixTimeZone.getTimeZone(name);
|
||||
else version(Windows)
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
if(auto windowsTZName = tzDatabaseNameToWindowsTZName(name))
|
||||
{
|
||||
try
|
||||
|
@ -27258,7 +27258,7 @@ private:
|
|||
+/
|
||||
final class UTC : TimeZone
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -27392,7 +27392,7 @@ private:
|
|||
+/
|
||||
final class SimpleTimeZone : TimeZone
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -28718,7 +28718,7 @@ else version(Windows)
|
|||
{
|
||||
final class WindowsTimeZone : TimeZone
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
import std.conv : to;
|
||||
import std.algorithm : sort;
|
||||
import std.array : appender;
|
||||
|
@ -29547,7 +29547,7 @@ string tzDatabaseNameToWindowsTZName(string tzName) @safe pure nothrow @nogc
|
|||
|
||||
version(Windows) unittest
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
foreach(tzName; TimeZone.getInstalledTZNames())
|
||||
assert(tzDatabaseNameToWindowsTZName(tzName) !is null, format("TZName which failed: %s", tzName));
|
||||
}
|
||||
|
@ -29692,7 +29692,7 @@ string windowsTZNameToTZDatabaseName(string tzName) @safe pure nothrow @nogc
|
|||
|
||||
version(Windows) unittest
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
foreach(tzName; WindowsTimeZone.getInstalledTZNames())
|
||||
assert(windowsTZNameToTZDatabaseName(tzName) !is null, format("TZName which failed: %s", tzName));
|
||||
}
|
||||
|
@ -30205,7 +30205,7 @@ static bool yearIsLeapYear(int year) @safe pure nothrow
|
|||
|
||||
unittest
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
foreach(year; [1, 2, 3, 5, 6, 7, 100, 200, 300, 500, 600, 700, 1998, 1999,
|
||||
2001, 2002, 2003, 2005, 2006, 2007, 2009, 2010, 2011])
|
||||
{
|
||||
|
@ -31471,7 +31471,7 @@ bool validTimeUnits(string[] units...) @safe pure nothrow
|
|||
+/
|
||||
int cmpTimeUnits(string lhs, string rhs) @safe pure
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
import std.algorithm : countUntil;
|
||||
|
||||
auto tstrings = timeStrings;
|
||||
|
@ -31643,7 +31643,7 @@ void enforceValid(string units)(int value, string file = __FILE__, size_t line =
|
|||
units == "minutes" ||
|
||||
units == "seconds")
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
|
||||
static if(units == "months")
|
||||
{
|
||||
|
@ -31685,7 +31685,7 @@ void enforceValid(string units)
|
|||
(int year, Month month, int day, string file = __FILE__, size_t line = __LINE__) @safe pure
|
||||
if(units == "days")
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
if(!valid!"days"(year, month, day))
|
||||
throw new DateTimeException(format("%s is not a valid day in %s in %s", day, month, year), file, line);
|
||||
}
|
||||
|
@ -32317,7 +32317,7 @@ unittest
|
|||
+/
|
||||
string monthToString(Month month) @safe pure
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
assert(month >= Month.jan && month <= Month.dec, format("Invalid month: %s", month));
|
||||
return _monthNames[month - Month.jan];
|
||||
}
|
||||
|
@ -32350,7 +32350,7 @@ unittest
|
|||
+/
|
||||
Month monthFromString(string monthStr) @safe pure
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
switch(monthStr)
|
||||
{
|
||||
case "Jan":
|
||||
|
@ -32456,7 +32456,7 @@ unittest
|
|||
+/
|
||||
static string fracSecsToISOString(int hnsecs) @safe pure nothrow
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
assert(hnsecs >= 0);
|
||||
|
||||
try
|
||||
|
|
|
@ -1301,7 +1301,7 @@ struct EmailStatus
|
|||
/// Returns a textual representation of the email status
|
||||
string toString ()
|
||||
{
|
||||
import std.string;
|
||||
import std.format : format;
|
||||
return format("EmailStatus\n{\n\tvalid: %s\n\tlocalPart: %s\n\tdomainPart: %s\n\tstatusCode: %s\n}", valid,
|
||||
localPart, domainPart, statusCode);
|
||||
}
|
||||
|
|
|
@ -4187,7 +4187,7 @@ unittest
|
|||
void next(ref char[] buf)
|
||||
{
|
||||
file.readln(buf);
|
||||
import std.string;
|
||||
import std.string : chomp;
|
||||
buf = chomp(buf);
|
||||
}
|
||||
|
||||
|
|
|
@ -2895,12 +2895,14 @@ string expandTilde(string inputPath)
|
|||
}
|
||||
else
|
||||
{
|
||||
import std.string : indexOf;
|
||||
|
||||
assert(path.length > 2 || (path.length == 2 && !isDirSeparator(path[1])));
|
||||
assert(path[0] == '~');
|
||||
|
||||
// Extract username, searching for path separator.
|
||||
string username;
|
||||
auto last_char = std.string.indexOf(path, dirSeparator[0]);
|
||||
auto last_char = indexOf(path, dirSeparator[0]);
|
||||
|
||||
if (last_char == -1)
|
||||
{
|
||||
|
|
|
@ -646,14 +646,14 @@ unittest
|
|||
{
|
||||
void test(alias matchFn)()
|
||||
{
|
||||
import std.string : toUpper;
|
||||
import std.uni : toUpper;
|
||||
|
||||
foreach(i, v; TypeTuple!(string, wstring, dstring))
|
||||
{
|
||||
auto baz(Cap)(Cap m)
|
||||
if (is(Cap == Captures!(Cap.String)))
|
||||
{
|
||||
return std.string.toUpper(m.hit);
|
||||
return toUpper(m.hit);
|
||||
}
|
||||
alias String = v;
|
||||
assert(std.regex.replace!(matchFn)(to!String("ark rapacity"), regex(to!String("r")), to!String("c"))
|
||||
|
|
|
@ -490,7 +490,7 @@ Throws: $(D ErrnoException) in case of error.
|
|||
void windowsHandleOpen(HANDLE handle, in char[] stdioOpenmode)
|
||||
{
|
||||
import std.exception : errnoEnforce;
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
|
||||
// Create file descriptors from the handles
|
||||
version (DIGITAL_MARS_STDIO)
|
||||
|
@ -630,7 +630,7 @@ Throws: $(D ErrnoException) on error.
|
|||
scope(exit) _p.handle = null; // nullify the handle anyway
|
||||
version (Posix)
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
|
||||
if (_p.isPopened)
|
||||
{
|
||||
|
|
|
@ -534,7 +534,7 @@ unittest
|
|||
private template fqnType(T,
|
||||
bool alreadyConst, bool alreadyImmutable, bool alreadyShared, bool alreadyInout)
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
|
||||
// Convenience tags
|
||||
enum {
|
||||
|
@ -740,7 +740,7 @@ private template fqnType(T,
|
|||
|
||||
unittest
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
alias fqn = fullyQualifiedName;
|
||||
|
||||
// Verify those 2 are the same for simple case
|
||||
|
|
20
std/uni.d
20
std/uni.d
|
@ -2350,7 +2350,7 @@ public:
|
|||
unittest
|
||||
{
|
||||
import std.conv : to;
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
import std.uni : unicode;
|
||||
|
||||
assert(unicode.Cyrillic.to!string ==
|
||||
|
@ -2369,7 +2369,7 @@ public:
|
|||
unittest
|
||||
{
|
||||
import std.exception : assertThrown;
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
assertThrown!FormatException(format("%a", unicode.ASCII));
|
||||
}
|
||||
|
||||
|
@ -2538,7 +2538,7 @@ public:
|
|||
string toSourceCode(string funcName="")
|
||||
{
|
||||
import std.array : array;
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
import std.algorithm : countUntil;
|
||||
enum maxBinary = 3;
|
||||
static string linearScope(R)(R ivals, string indent)
|
||||
|
@ -4740,7 +4740,7 @@ template Utf8Matcher()
|
|||
// from 3 primitives: tab!(size), lookup and Sizes
|
||||
mixin template DefMatcher()
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
enum hasASCII = staticIndexOf!(1, Sizes) >= 0;
|
||||
alias UniSizes = Erase!(1, Sizes);
|
||||
|
||||
|
@ -5376,7 +5376,7 @@ package auto units(C)(C[] s)
|
|||
unittest
|
||||
{
|
||||
import std.exception : collectException;
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
import std.algorithm;
|
||||
auto utf16 = utfMatcher!wchar(unicode.L);
|
||||
auto utf8 = utfMatcher!char(unicode.L);
|
||||
|
@ -8496,7 +8496,7 @@ S toLower(S)(S s) @trusted pure
|
|||
|
||||
@trusted unittest //@@@BUG std.format is not @safe
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
foreach(ch; 0..0x80)
|
||||
assert(std.ascii.toLower(ch) == toLower(ch));
|
||||
assert(toLower('Я') == 'я');
|
||||
|
@ -8603,7 +8603,7 @@ dchar toUpper(dchar c)
|
|||
|
||||
@trusted unittest
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
foreach(ch; 0..0x80)
|
||||
assert(std.ascii.toUpper(ch) == toUpper(ch));
|
||||
assert(toUpper('я') == 'Я');
|
||||
|
@ -8671,7 +8671,7 @@ unittest
|
|||
{
|
||||
static void doTest(C)(const(C)[] s, const(C)[] trueUp, const(C)[] trueLow)
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
string diff = "src: %( %x %)\nres: %( %x %)\ntru: %( %x %)";
|
||||
auto low = s.toLower() , up = s.toUpper();
|
||||
auto lowInp = s.dup, upInp = s.dup;
|
||||
|
@ -8834,7 +8834,7 @@ bool isSymbol(dchar c)
|
|||
|
||||
unittest
|
||||
{
|
||||
import std.string;
|
||||
import std.format : format;
|
||||
assert(isSymbol('\u0024'));
|
||||
assert(isSymbol('\u002B'));
|
||||
assert(isSymbol('\u005E'));
|
||||
|
@ -8881,7 +8881,7 @@ bool isGraphical(dchar c)
|
|||
unittest
|
||||
{
|
||||
auto set = unicode("Graphical");
|
||||
import std.string;
|
||||
import std.format : format;
|
||||
foreach(ch; set.byCodepoint)
|
||||
assert(isGraphical(ch), format("%4x", ch));
|
||||
foreach(ch; 0..0x4000)
|
||||
|
|
|
@ -397,19 +397,19 @@ size_t uriLength(Char)(in Char[] s) if (isSomeChar!Char)
|
|||
* https://
|
||||
* www.
|
||||
*/
|
||||
import std.string : icmp;
|
||||
import std.uni : icmp;
|
||||
|
||||
size_t i;
|
||||
|
||||
if (s.length <= 4)
|
||||
return -1;
|
||||
|
||||
if (s.length > 7 && std.string.icmp(s[0 .. 7], "http://") == 0) {
|
||||
if (s.length > 7 && icmp(s[0 .. 7], "http://") == 0) {
|
||||
i = 7;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (s.length > 8 && std.string.icmp(s[0 .. 8], "https://") == 0)
|
||||
if (s.length > 8 && icmp(s[0 .. 8], "https://") == 0)
|
||||
i = 8;
|
||||
else
|
||||
return -1;
|
||||
|
|
|
@ -1565,7 +1565,7 @@ public class UUIDParsingException : Exception
|
|||
Throwable next = null, string file = __FILE__, size_t line = __LINE__) pure @trusted
|
||||
{
|
||||
import std.array : replace;
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
this.input = input;
|
||||
this.position = pos;
|
||||
this.reason = why;
|
||||
|
|
|
@ -954,7 +954,7 @@ public:
|
|||
{
|
||||
string tryUseType(string tp)
|
||||
{
|
||||
import std.string : format;
|
||||
import std.format : format;
|
||||
return q{
|
||||
static if (allowed!%1$s && T.allowed!%1$s)
|
||||
if (convertsTo!%1$s && other.convertsTo!%1$s)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue