46 changes: 23 additions & 23 deletions std/experimental/ndslice/iteration.d
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ body
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.selection: iotaSlice;
import std.experimental.ndslice.selection : iotaSlice;
assert(iotaSlice(3, 4, 5, 6)
.swapped!(3, 1)
.shape == cast(size_t[4])[3, 6, 5, 4]);
Expand All @@ -184,7 +184,7 @@ body
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.selection: iotaSlice;
import std.experimental.ndslice.selection : iotaSlice;
assert(iotaSlice(3, 4, 5, 6)
.swapped(1, 3)
.shape == cast(size_t[4])[3, 6, 5, 4]);
Expand All @@ -194,7 +194,7 @@ body
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.selection: iotaSlice;
import std.experimental.ndslice.selection : iotaSlice;
assert(iotaSlice(3, 4)
.swapped
.shape == cast(size_t[2])[4, 3]);
Expand Down Expand Up @@ -284,7 +284,7 @@ body
@safe pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.selection: iotaSlice;
import std.experimental.ndslice.selection : iotaSlice;
auto slice = iotaSlice(2, 3);

auto a = [[0, 1, 2],
Expand Down Expand Up @@ -351,7 +351,7 @@ Slice!(N, Range) everted(size_t N, Range)(auto ref Slice!(N, Range) slice)
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.selection: iotaSlice;
import std.experimental.ndslice.selection : iotaSlice;
assert(iotaSlice(3, 4, 5)
.everted
.shape == cast(size_t[3])[5, 4, 3]);
Expand Down Expand Up @@ -465,7 +465,7 @@ Slice!(2, Range) transposed(Range)(auto ref Slice!(2, Range) slice)
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.selection: iotaSlice;
import std.experimental.ndslice.selection : iotaSlice;
assert(iotaSlice(3, 4, 5, 6, 7)
.transposed!(4, 1, 0)
.shape == cast(size_t[5])[7, 4, 3, 5, 6]);
Expand All @@ -475,7 +475,7 @@ Slice!(2, Range) transposed(Range)(auto ref Slice!(2, Range) slice)
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.selection: iotaSlice;
import std.experimental.ndslice.selection : iotaSlice;
assert(iotaSlice(3, 4, 5, 6, 7)
.transposed(4, 1, 0)
.shape == cast(size_t[5])[7, 4, 3, 5, 6]);
Expand All @@ -485,7 +485,7 @@ Slice!(2, Range) transposed(Range)(auto ref Slice!(2, Range) slice)
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.selection: iotaSlice;
import std.experimental.ndslice.selection : iotaSlice;
assert(iotaSlice(3, 4, 5, 6, 7)
.transposed(4)
.shape == cast(size_t[5])[7, 3, 4, 5, 6]);
Expand All @@ -495,7 +495,7 @@ Slice!(2, Range) transposed(Range)(auto ref Slice!(2, Range) slice)
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.selection: iotaSlice;
import std.experimental.ndslice.selection : iotaSlice;
assert(iotaSlice(3, 4)
.transposed
.shape == cast(size_t[2])[4, 3]);
Expand Down Expand Up @@ -530,7 +530,7 @@ Slice!(N, Range) allReversed(size_t N, Range)(Slice!(N, Range) slice)
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.range: iota, retro;
import std.range : iota, retro;
auto a = 20.iota.sliced(4, 5).allReversed;
auto b = 20.iota.retro.sliced(4, 5);
assert(a == b);
Expand Down Expand Up @@ -615,8 +615,8 @@ pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.selection;
import std.algorithm.comparison: equal;
import std.range: iota, retro, chain;
import std.algorithm.comparison : equal;
import std.range : iota, retro, chain;
auto i0 = iota(0, 4); auto r0 = i0.retro;
auto i1 = iota(4, 8); auto r1 = i1.retro;
auto i2 = iota(8, 12); auto r2 = i2.retro;
Expand Down Expand Up @@ -723,7 +723,7 @@ pure nothrow unittest
///
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.selection: iotaSlice;
import std.experimental.ndslice.selection : iotaSlice;
static assert(iotaSlice(13, 40).strided!(0, 1)(2, 5).shape == [7, 8]);
static assert(iotaSlice(93).strided!(0, 0)(7, 3).shape == [5]);
}
Expand All @@ -732,8 +732,8 @@ pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.selection;
import std.algorithm.comparison: equal;
import std.range: iota, stride, chain;
import std.algorithm.comparison : equal;
import std.range : iota, stride, chain;
auto i0 = iota(0, 4); auto s0 = i0.stride(3);
auto i1 = iota(4, 8); auto s1 = i1.stride(3);
auto i2 = iota(8, 12); auto s2 = i2.stride(3);
Expand Down Expand Up @@ -778,7 +778,7 @@ Slice!(N, Range) allDropBackOne(size_t N, Range)(Slice!(N, Range) slice)
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.selection: iotaSlice;
import std.experimental.ndslice.selection : iotaSlice;
auto a = iotaSlice(4, 5);

assert(a.allDropOne[0, 0] == 6);
Expand Down Expand Up @@ -823,7 +823,7 @@ Slice!(N, Range) allDropBackExactly(size_t N, Range)(Slice!(N, Range) slice, siz
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.selection: iotaSlice;
import std.experimental.ndslice.selection : iotaSlice;
auto a = iotaSlice(4, 5);

assert(a.allDropExactly(2)[0, 0] == 12);
Expand Down Expand Up @@ -865,7 +865,7 @@ Slice!(N, Range) allDropBack(size_t N, Range)(Slice!(N, Range) slice, size_t n)
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.selection: iotaSlice;
import std.experimental.ndslice.selection : iotaSlice;
auto a = iotaSlice(4, 5);

assert(a.allDrop(2)[0, 0] == 12);
Expand Down Expand Up @@ -973,7 +973,7 @@ body
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.selection: iotaSlice;
import std.experimental.ndslice.selection : iotaSlice;
auto a = iotaSlice(4, 5);

assert(a.dropOne!(1, 0)[0, 0] == 6);
Expand All @@ -998,7 +998,7 @@ body
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.selection: iotaSlice;
import std.experimental.ndslice.selection : iotaSlice;
auto a = iotaSlice(4, 5);

assert(a.dropOne(0).dropOne(0)[0, 0] == 10);
Expand Down Expand Up @@ -1083,7 +1083,7 @@ body
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.selection: iotaSlice;
import std.experimental.ndslice.selection : iotaSlice;
auto a = iotaSlice(4, 5);

assert(a.dropExactly !(1, 0)(2, 3)[0, 0] == 17);
Expand Down Expand Up @@ -1173,7 +1173,7 @@ body
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.selection: iotaSlice;
import std.experimental.ndslice.selection : iotaSlice;
auto a = iotaSlice(4, 5);

assert(a.drop !(1, 0)(2, 3)[0, 0] == 17);
Expand Down Expand Up @@ -1213,7 +1213,7 @@ body
///
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.selection: iotaSlice;
import std.experimental.ndslice.selection : iotaSlice;
assert(iotaSlice(5, 3, 6, 7)
.dropToHypercube
.shape == cast(size_t[4])[3, 3, 3, 3]);
Expand Down
44 changes: 22 additions & 22 deletions std/experimental/ndslice/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ Returns:
Slice!(3, C*) movingWindowByChannel(alias filter, C)
(Slice!(3, C*) image, size_t nr, size_t nc)
{
import std.algorithm.iteration: map;
import std.array: array;
import std.algorithm.iteration : map;
import std.array : array;
// 0. 3D
// The last dimension represents the color channel.
Expand Down Expand Up @@ -219,7 +219,7 @@ Returns:
+/
T median(Range, T)(Range r, T[] buf)
{
import std.algorithm.sorting: topN;
import std.algorithm.sorting : topN;
size_t n;
foreach (e; r)
buf[n++] = e;
Expand All @@ -234,9 +234,9 @@ The `main` function:
-------
void main(string[] args)
{
import std.conv: to;
import std.getopt: getopt, defaultGetoptPrinter;
import std.path: stripExtension;
import std.conv : to;
import std.getopt : getopt, defaultGetoptPrinter;
import std.path : stripExtension;
uint nr, nc, def = 3;
auto helpInformation = args.getopt(
Expand Down Expand Up @@ -339,8 +339,8 @@ unittest
static Slice!(3, ubyte*) movingWindowByChannel
(Slice!(3, ubyte*) image, size_t nr, size_t nc, ubyte delegate(Slice!(2, ubyte*)) filter)
{
import std.algorithm.iteration: map;
import std.array: array;
import std.algorithm.iteration : map;
import std.array : array;
auto wnds = image
.pack!1
.windows(nr, nc)
Expand All @@ -356,7 +356,7 @@ unittest

static T median(Range, T)(Range r, T[] buf)
{
import std.algorithm.sorting: topN;
import std.algorithm.sorting : topN;
size_t n;
foreach (e; r)
buf[n++] = e;
Expand All @@ -365,9 +365,9 @@ unittest
return buf[m];
}

import std.conv: to;
import std.getopt: getopt, defaultGetoptPrinter;
import std.path: stripExtension;
import std.conv : to;
import std.getopt : getopt, defaultGetoptPrinter;
import std.path : stripExtension;

auto args = ["std"];
uint nr, nc, def = 3;
Expand Down Expand Up @@ -396,8 +396,8 @@ unittest

@safe @nogc pure nothrow unittest
{
import std.algorithm.comparison: equal;
import std.range: iota;
import std.algorithm.comparison : equal;
import std.range : iota;
immutable r = 1000.iota;

auto t0 = r.sliced(1000);
Expand Down Expand Up @@ -425,9 +425,9 @@ unittest

pure nothrow unittest
{
import std.algorithm.comparison: equal;
import std.array: array;
import std.range: iota;
import std.algorithm.comparison : equal;
import std.array : array;
import std.range : iota;
auto r = 1000.iota.array;

auto t0 = r.sliced(1000);
Expand Down Expand Up @@ -517,7 +517,7 @@ pure nothrow unittest

@safe @nogc pure nothrow unittest
{
import std.range: iota;
import std.range : iota;
auto r = (10_000L * 2 * 3 * 4).iota;

auto t0 = r.sliced(10, 20, 30, 40);
Expand All @@ -530,10 +530,10 @@ pure nothrow unittest

pure nothrow unittest
{
import std.experimental.ndslice.internal: Iota;
import std.meta: AliasSeq;
import std.experimental.ndslice.internal : Iota;
import std.meta : AliasSeq;
import std.range;
import std.typecons: Tuple;
import std.typecons : Tuple;
foreach (R; AliasSeq!(
int*, int[], typeof(1.iota),
const(int)*, const(int)[],
Expand Down Expand Up @@ -561,7 +561,7 @@ pure nothrow unittest

pure nothrow unittest
{
import std.experimental.ndslice.selection: pack;
import std.experimental.ndslice.selection : pack;
auto slice = new int[24].sliced(2, 3, 4);
auto r0 = slice.pack!1[1, 2];
slice.pack!1[1, 2][] = 4;
Expand Down
80 changes: 40 additions & 40 deletions std/experimental/ndslice/selection.d
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ template pack(K...)
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.range.primitives: ElementType;
import std.range: iota;
import std.range.primitives : ElementType;
import std.range : iota;
auto r = (3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11).iota;
auto a = r.sliced(3, 4, 5, 6, 7, 8, 9, 10, 11);
auto b = a.pack!(2, 3); // same as `a.pack!2.pack!3`
Expand Down Expand Up @@ -203,7 +203,7 @@ evertPack(size_t N, Range)(auto ref Slice!(N, Range) slice)
///
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.iteration: transposed;
import std.experimental.ndslice.iteration : transposed;
auto slice = iotaSlice(3, 4, 5, 6, 7, 8, 9, 10, 11);
assert(slice
.pack!2
Expand All @@ -218,10 +218,10 @@ evertPack(size_t N, Range)(auto ref Slice!(N, Range) slice)
pure nothrow unittest
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.iteration: transposed;
import std.range.primitives: ElementType;
import std.range: iota;
import std.algorithm.comparison: equal;
import std.experimental.ndslice.iteration : transposed;
import std.range.primitives : ElementType;
import std.range : iota;
import std.algorithm.comparison : equal;
auto r = (3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11).iota;
auto a = r.sliced(3, 4, 5, 6, 7, 8, 9, 10, 11);
auto b = a
Expand Down Expand Up @@ -310,8 +310,8 @@ Slice!(1, Range) diagonal(size_t N, Range)(auto ref Slice!(N, Range) slice)
/// Non-square matrix
@safe @nogc pure nothrow unittest
{
import std.algorithm.comparison: equal;
import std.range: only;
import std.algorithm.comparison : equal;
import std.range : only;

// -------
// | 0 1 |
Expand Down Expand Up @@ -344,7 +344,7 @@ pure nothrow unittest
/// Matrix, subdiagonal
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.iteration: dropOne;
import std.experimental.ndslice.iteration : dropOne;
// -------
// | 0 1 2 |
// | 3 4 5 |
Expand All @@ -358,7 +358,7 @@ pure nothrow unittest
/// Matrix, antidiagonal
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.iteration: dropToHypercube, reversed;
import std.experimental.ndslice.iteration : dropToHypercube, reversed;
// -------
// | 0 1 2 |
// | 3 4 5 |
Expand Down Expand Up @@ -388,7 +388,7 @@ pure nothrow unittest
/// 3D, subdiagonal
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.iteration: dropOne;
import std.experimental.ndslice.iteration : dropOne;
// -----------
// | 0 1 2 |
// | 3 4 5 |
Expand All @@ -405,7 +405,7 @@ pure nothrow unittest
/// 3D, diagonal plain
@nogc @safe pure nothrow unittest
{
import std.experimental.ndslice.iteration: dropOne;
import std.experimental.ndslice.iteration : dropOne;
// -----------
// | 0 1 2 |
// | 3 4 5 |
Expand Down Expand Up @@ -783,7 +783,7 @@ Slice!(Lengths.length, Range)
///
@safe pure unittest
{
import std.experimental.ndslice.iteration: allReversed;
import std.experimental.ndslice.iteration : allReversed;
auto slice = iotaSlice(3, 4)
.allReversed
.reshape(-1, 3);
Expand All @@ -798,8 +798,8 @@ Slice!(Lengths.length, Range)
pure unittest
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.iteration: reversed;
import std.array: array;
import std.experimental.ndslice.iteration : reversed;
import std.array : array;

auto reshape2(S, L...)(S slice, L lengths)
{
Expand Down Expand Up @@ -827,7 +827,7 @@ pure unittest

@safe pure unittest
{
import std.experimental.ndslice.iteration: allReversed;
import std.experimental.ndslice.iteration : allReversed;
auto slice = iotaSlice(1, 1, 3, 2, 1, 2, 1).allReversed;
assert(slice.reshape(1, -1, 1, 1, 3, 1) ==
[[[[[[11], [10], [9]]]],
Expand All @@ -845,8 +845,8 @@ unittest
@safe pure unittest
{
import std.experimental.ndslice.slice;
import std.range: iota;
import std.exception: assertThrown;
import std.range : iota;
import std.exception : assertThrown;

auto e = 1.iotaSlice(1);
// resize to the wrong dimension
Expand Down Expand Up @@ -1165,8 +1165,8 @@ auto byElement(size_t N, Range)(auto ref Slice!(N, Range) slice)
/// Regular slice
@safe @nogc pure nothrow unittest
{
import std.algorithm.comparison: equal;
import std.range: iota;
import std.algorithm.comparison : equal;
import std.range : iota;
assert(iotaSlice(4, 5)
.byElement
.equal(20.iota));
Expand All @@ -1177,7 +1177,7 @@ auto byElement(size_t N, Range)(auto ref Slice!(N, Range) slice)
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.iteration;
import std.range: drop;
import std.range : drop;
assert(iotaSlice(3, 4, 5, 6, 7)
.pack!2
.byElement()
Expand Down Expand Up @@ -1222,8 +1222,8 @@ pure nothrow unittest
pure nothrow unittest
{
// test save
import std.range: dropOne;
import std.range: iota;
import std.range : dropOne;
import std.range : iota;

auto elems = 12.iota.sliced(3, 4).byElement;
assert(elems.front == 0);
Expand All @@ -1237,9 +1237,9 @@ Random access and slicing
@nogc nothrow unittest
{
import std.experimental.ndslice.slice;
import std.algorithm.comparison: equal;
import std.array: array;
import std.range: iota, repeat;
import std.algorithm.comparison : equal;
import std.array : array;
import std.range : iota, repeat;
static data = 20.iota.array;
auto elems = data.sliced(4, 5).byElement;

Expand Down Expand Up @@ -1275,8 +1275,8 @@ Use $(SUBREF iteration, allReversed) in pipeline before
+/
@safe @nogc pure nothrow unittest
{
import std.range: retro;
import std.experimental.ndslice.iteration: allReversed;
import std.range : retro;
import std.experimental.ndslice.iteration : allReversed;

auto slice = iotaSlice(3, 4, 5);

Expand All @@ -1301,7 +1301,7 @@ Use $(SUBREF iteration, allReversed) in pipeline before

@safe @nogc pure nothrow unittest
{
import std.range.primitives: isRandomAccessRange, hasSlicing;
import std.range.primitives : isRandomAccessRange, hasSlicing;
auto elems = iotaSlice(4, 5).byElement;
static assert(isRandomAccessRange!(typeof(elems)));
static assert(hasSlicing!(typeof(elems)));
Expand All @@ -1311,7 +1311,7 @@ Use $(SUBREF iteration, allReversed) in pipeline before
@safe @nogc pure nothrow unittest
{
import std.experimental.ndslice.iteration;
import std.range: isRandomAccessRange;
import std.range : isRandomAccessRange;
auto elems = iotaSlice(4, 5).everted.byElement;
static assert(isRandomAccessRange!(typeof(elems)));

Expand All @@ -1328,8 +1328,8 @@ Use $(SUBREF iteration, allReversed) in pipeline before
{
import std.experimental.ndslice.slice;
import std.experimental.ndslice.iteration;
import std.range: iota, isForwardRange, hasLength;
import std.algorithm.comparison: equal;
import std.range : iota, isForwardRange, hasLength;
import std.algorithm.comparison : equal;

auto range = (3 * 4 * 5 * 6 * 7).iota;
auto slice0 = range.sliced(3, 4, 5, 6, 7);
Expand Down Expand Up @@ -1532,7 +1532,7 @@ pure nothrow unittest
/// Properties
@safe @nogc pure nothrow unittest
{
import std.range.primitives: popFrontN;
import std.range.primitives : popFrontN;

auto elems = iotaSlice(3, 4).byElementInStandardSimplex;

Expand All @@ -1548,7 +1548,7 @@ pure nothrow unittest
@safe @nogc pure nothrow unittest
{
auto elems = iotaSlice(3, 4).byElementInStandardSimplex;
import std.range: dropOne, popFrontN;
import std.range : dropOne, popFrontN;
elems.popFrontN(4);

assert(elems.save.dropOne.front == 8);
Expand Down Expand Up @@ -1578,7 +1578,7 @@ IndexSlice!(Lengths.length) indexSlice(Lengths...)(Lengths lengths)
///ditto
IndexSlice!N indexSlice(size_t N)(auto ref size_t[N] lengths)
{
import std.experimental.ndslice.slice: sliced;
import std.experimental.ndslice.slice : sliced;
with (typeof(return)) return Range(lengths[1 .. $]).sliced(lengths);
}

Expand Down Expand Up @@ -1612,7 +1612,7 @@ IndexSlice!N indexSlice(size_t N)(auto ref size_t[N] lengths)
@safe pure nothrow unittest
{
// test save
import std.range: dropOne;
import std.range : dropOne;

auto im = indexSlice(7, 9);
auto imByElement = im.byElement;
Expand Down Expand Up @@ -1657,7 +1657,7 @@ template IndexSlice(size_t N)
unittest
{
auto r = indexSlice(1);
import std.range.primitives: isRandomAccessRange;
import std.range.primitives : isRandomAccessRange;
static assert(isRandomAccessRange!(typeof(r)));
}

Expand All @@ -1682,7 +1682,7 @@ IotaSlice!(Lengths.length) iotaSlice(Lengths...)(Lengths lengths)
///ditto
IotaSlice!N iotaSlice(size_t N)(auto ref size_t[N] lengths, size_t shift = 0)
{
import std.experimental.ndslice.slice: sliced;
import std.experimental.ndslice.slice : sliced;
with (typeof(return)) return Range.init.sliced(lengths, shift);
}

Expand All @@ -1696,7 +1696,7 @@ IotaSlice!N iotaSlice(size_t N)(auto ref size_t[N] lengths, size_t shift = 0)

assert(slice == array);

import std.range.primitives: isRandomAccessRange;
import std.range.primitives : isRandomAccessRange;
static assert(isRandomAccessRange!(IotaSlice!2));
static assert(is(IotaSlice!2 : Slice!(2, Range), Range));
static assert(is(DeepElementType!(IotaSlice!2) == size_t));
Expand Down
130 changes: 65 additions & 65 deletions std/experimental/ndslice/slice.d

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions std/experimental/typecons.d
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module std.experimental.typecons;
import std.meta; // : AliasSeq, allSatisfy;
import std.traits;

import std.typecons: Tuple, tuple, Bind, DerivedFunctionType,
import std.typecons : Tuple, tuple, Bind, DerivedFunctionType,
isImplicitlyConvertible, mixinAll, staticIota,
GetOverloadedMethods;

Expand Down Expand Up @@ -568,7 +568,7 @@ template unwrap(Target)
break;
}
} while (upCastSource);
import std.conv: ConvException;
import std.conv : ConvException;
throw new ConvException(unwrapExceptionText!(Source,Target));
}
// structural downcast for class target
Expand Down
6 changes: 3 additions & 3 deletions std/file.d
Original file line number Diff line number Diff line change
Expand Up @@ -2486,8 +2486,8 @@ version(Posix) unittest // input range of dchars
mkdirRecurse(deleteme);
scope(exit) if (deleteme.exists) rmdirRecurse(deleteme);
write(deleteme ~ "/f", "");
import std.range.interfaces: InputRange, inputRangeObject;
import std.utf: byChar;
import std.range.interfaces : InputRange, inputRangeObject;
import std.utf : byChar;
immutable string link = deleteme ~ "/l";
symlink("f", link);
InputRange!dchar linkr = inputRangeObject(link);
Expand Down Expand Up @@ -3459,7 +3459,7 @@ version(Windows) unittest

version(Posix) unittest
{
import std.process: executeShell;
import std.process : executeShell;
collectException(rmdirRecurse(deleteme));
auto d = deleteme~"/a/b/c/d/e/f/g";
enforce(collectException(mkdir(d)));
Expand Down
6 changes: 3 additions & 3 deletions std/functional.d
Original file line number Diff line number Diff line change
Expand Up @@ -909,9 +909,9 @@ template compose(fun...)
///
unittest
{
import std.algorithm: equal, map;
import std.array: split;
import std.conv: to;
import std.algorithm : equal, map;
import std.array : split;
import std.conv : to;

// First split a string in whitespace-separated tokens and then
// convert each token into an integer
Expand Down
4 changes: 2 additions & 2 deletions std/getopt.d
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,8 @@ follow this pattern:
*/
private template optionValidator(A...)
{
import std.typecons: staticIota;
import std.format: format;
import std.typecons : staticIota;
import std.format : format;

enum fmt = "getopt validator: %s (at position %d)";
enum isReceiver(T) = isPointer!T || (is(T==function)) || (is(T==delegate));
Expand Down
12 changes: 6 additions & 6 deletions std/internal/cstring.d
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ unittest
{
version(Posix)
{
import core.stdc.stdlib: free;
import core.sys.posix.stdlib: setenv;
import std.exception: enforce;
import core.stdc.stdlib : free;
import core.sys.posix.stdlib : setenv;
import std.exception : enforce;

void setEnvironment(in char[] name, in char[] value)
{ enforce(setenv(name.tempCString(), value.tempCString(), 1) != -1); }
}

version(Windows)
{
import core.sys.windows.windows: SetEnvironmentVariableW;
import std.exception: enforce;
import core.sys.windows.windows : SetEnvironmentVariableW;
import std.exception : enforce;

void setEnvironment(in char[] name, in char[] value)
{ enforce(SetEnvironmentVariableW(name.tempCStringW(), value.tempCStringW())); }
Expand Down Expand Up @@ -149,7 +149,7 @@ auto tempCString(To = char, From)(From str)
{
pragma(inline, false); // because it's rarely called

import core.exception : onOutOfMemoryError;
import core.exception : onOutOfMemoryError;
import core.stdc.string : memcpy;
import core.stdc.stdlib : malloc, realloc;

Expand Down
2 changes: 1 addition & 1 deletion std/internal/math/biguintcore.d
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ else static if (BigDigit.sizeof == long.sizeof)
else static assert(0, "Unsupported BigDigit size");

private import std.exception : assumeUnique;
private import std.traits:isIntegral;
private import std.traits : isIntegral;
enum BigDigitBits = BigDigit.sizeof*8;
template maxBigDigits(T) if (isIntegral!T)
{
Expand Down
2 changes: 1 addition & 1 deletion std/internal/math/gammafunction.d
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@ unittest {
*/
real logmdigammaInverse(real y)
{
import std.numeric: findRoot;
import std.numeric : findRoot;
// FIXME: should be returned back to enum.
// Fix requires CTFEable `log` on non-x86 targets (check both LDC and GDC).
immutable maxY = logmdigamma(real.min_normal);
Expand Down
2 changes: 1 addition & 1 deletion std/json.d
Original file line number Diff line number Diff line change
Expand Up @@ -1652,7 +1652,7 @@ EOF";
// handling of special float values (NaN, Inf, -Inf)
unittest
{
import std.math : isNaN, isInfinity;
import std.math : isNaN, isInfinity;
import std.exception : assertThrown;

// expected representations of NaN and Inf
Expand Down
6 changes: 3 additions & 3 deletions std/math.d
Original file line number Diff line number Diff line change
Expand Up @@ -2614,7 +2614,7 @@ unittest

unittest
{
import std.meta: AliasSeq;
import std.meta : AliasSeq;
void foo() {
foreach (T; AliasSeq!(real, double, float))
{
Expand Down Expand Up @@ -7466,7 +7466,7 @@ T nextPow2(T)(const T val) if (isFloatingPoint!T)

@safe @nogc pure nothrow unittest
{
import std.meta: AliasSeq;
import std.meta : AliasSeq;

foreach (T; AliasSeq!(float, double, real))
{
Expand Down Expand Up @@ -7594,7 +7594,7 @@ T truncPow2(T)(const T val) if (isFloatingPoint!T)

@safe @nogc pure nothrow unittest
{
import std.meta: AliasSeq;
import std.meta : AliasSeq;

foreach (T; AliasSeq!(float, double, real))
{
Expand Down
10 changes: 5 additions & 5 deletions std/numeric.d
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ public:
void opAssign(F)(F input)
if (__traits(compiles, cast(real)input))
{
import std.conv: text;
import std.conv : text;
static if (staticIndexOf!(Unqual!F, float, double, real) >= 0)
auto value = ToBinary!(Unqual!F)(input);
else
Expand Down Expand Up @@ -527,7 +527,7 @@ public:
@property F get(F)()
if (staticIndexOf!(Unqual!F, float, double, real) >= 0)
{
import std.conv: text;
import std.conv : text;

ToBinary!F result;

Expand Down Expand Up @@ -1572,7 +1572,7 @@ unittest

unittest
{
import std.meta: AliasSeq;
import std.meta : AliasSeq;
foreach (T; AliasSeq!(double, float, real))
{
{
Expand Down Expand Up @@ -2491,7 +2491,7 @@ unittest

unittest
{
import std.conv: text;
import std.conv : text;
string[] s = ["Hello", "brave", "new", "world"];
string[] t = ["Hello", "new", "world"];
auto simIter = gapWeightedSimilarityIncremental(s, t, 1.0);
Expand Down Expand Up @@ -2621,7 +2621,7 @@ private:

void enforceSize(R)(R range) const
{
import std.conv: text;
import std.conv : text;
enforce(range.length <= size, text(
"FFT size mismatch. Expected ", size, ", got ", range.length));
}
Expand Down
2 changes: 1 addition & 1 deletion std/path.d
Original file line number Diff line number Diff line change
Expand Up @@ -3914,7 +3914,7 @@ string expandTilde(string inputPath) nothrow
}


version(unittest) import std.process: environment;
version(unittest) import std.process : environment;
unittest
{
version (Posix)
Expand Down
14 changes: 7 additions & 7 deletions std/process.d
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ private Pid spawnProcessImpl(in char[][] args,
in char[] workDir)
@trusted // TODO: Should be @safe
{
import core.exception: RangeError;
import core.exception : RangeError;
import std.path : isDirSeparator;
import std.algorithm : any;
import std.string : toStringz;
Expand Down Expand Up @@ -562,7 +562,7 @@ private Pid spawnProcessImpl(in char[] commandLine,
in char[] workDir)
@trusted
{
import core.exception: RangeError;
import core.exception : RangeError;

if (commandLine.empty) throw new RangeError("Command line is empty");

Expand Down Expand Up @@ -1474,7 +1474,7 @@ $(D SIGTERM) signal will be sent. (This matches the behaviour of the
$(LINK2 http://pubs.opengroup.org/onlinepubs/9699919799/utilities/kill.html,
$(D _kill)) shell command.)
---
import core.sys.posix.signal: SIGKILL;
import core.sys.posix.signal : SIGKILL;
auto pid = spawnProcess("some_app");
kill(pid, SIGKILL);
assert (wait(pid) == -SIGKILL); // Negative return value on POSIX!
Expand All @@ -1490,7 +1490,7 @@ void kill(Pid pid)
version (Windows) kill(pid, 1);
else version (Posix)
{
import core.sys.posix.signal: SIGTERM;
import core.sys.posix.signal : SIGTERM;
kill(pid, SIGTERM);
}
}
Expand Down Expand Up @@ -1527,7 +1527,7 @@ unittest // tryWait() and kill()
}
else version (Posix)
{
import core.sys.posix.signal: SIGTERM, SIGKILL;
import core.sys.posix.signal : SIGTERM, SIGKILL;
TestScript prog = "while true; do sleep 1; done";
}
auto pid = spawnProcess(prog.path);
Expand Down Expand Up @@ -3468,7 +3468,7 @@ version (StdDdoc)
}
else version (Windows)
{
import core.stdc.stdlib: _exit;
import core.stdc.stdlib : _exit;
_exit(wait(spawnProcess(commandLine)));
}
---
Expand All @@ -3492,7 +3492,7 @@ version (StdDdoc)
else version (Windows)
{
spawnProcess(commandLine);
import core.stdc.stdlib: _exit;
import core.stdc.stdlib : _exit;
_exit(0);
}
---
Expand Down
10 changes: 5 additions & 5 deletions std/range/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -3903,7 +3903,7 @@ pure unittest
///
pure unittest
{
import std.conv: to;
import std.conv : to;

int[] a = [ 1, 2, 3 ];
string[] b = [ "a", "b", "c" ];
Expand Down Expand Up @@ -7957,7 +7957,7 @@ if (isInputRange!Range)
///
unittest
{
import std.algorithm: equal;
import std.algorithm : equal;
auto a = assumeSorted([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]);
auto p = a.lowerBound(4);
assert(equal(p, [ 0, 1, 2, 3 ]));
Expand Down Expand Up @@ -8001,7 +8001,7 @@ See_Also: STL's $(WEB sgi.com/tech/stl/lower_bound.html,upper_bound).
///
unittest
{
import std.algorithm: equal;
import std.algorithm : equal;
auto a = assumeSorted([ 1, 2, 3, 3, 3, 4, 4, 5, 6 ]);
auto p = a.upperBound(3);
assert(equal(p, [4, 4, 5, 6]));
Expand Down Expand Up @@ -8064,7 +8064,7 @@ See_Also: STL's $(WEB sgi.com/tech/stl/lower_bound.html,upper_bound).
///
unittest
{
import std.algorithm: equal;
import std.algorithm : equal;
auto a = [ 1, 2, 3, 3, 3, 4, 4, 5, 6 ];
auto r = a.assumeSorted.equalRange(3);
assert(equal(r, [ 3, 3, 3 ]));
Expand Down Expand Up @@ -8124,7 +8124,7 @@ equalRange). Completes the entire search in $(BIGOH log(n)) time.
///
unittest
{
import std.algorithm: equal;
import std.algorithm : equal;
auto a = [ 1, 2, 3, 3, 3, 4, 4, 5, 6 ];
auto r = assumeSorted(a).trisect(3);
assert(equal(r[0], [ 1, 2 ]));
Expand Down
2 changes: 1 addition & 1 deletion std/range/primitives.d
Original file line number Diff line number Diff line change
Expand Up @@ -2160,7 +2160,7 @@ version(unittest)
void popBack(T)(ref T[] a) @safe pure
if (isNarrowString!(T[]))
{
import std.utf: strideBack;
import std.utf : strideBack;
assert(a.length, "Attempting to popBack() past the front of an array of " ~ T.stringof);
a = a[0 .. $ - strideBack(a, $)];
}
Expand Down
6 changes: 3 additions & 3 deletions std/regex/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ package void replaceFmt(R, Capt, OutR)
isOutputRange!(OutR, ElementEncodingType!(Capt.String)[]))
{
import std.algorithm, std.conv;
import std.ascii: isDigit, isAlpha;
import std.ascii : isDigit, isAlpha;
enum State { Normal, Dollar }
auto state = State.Normal;
size_t offset;
Expand Down Expand Up @@ -1209,7 +1209,7 @@ public R replaceFirst(alias fun, R, RegEx)(R input, RegEx re)
///
unittest
{
import std.conv: to;
import std.conv : to;
string list = "#21 out of 46";
string newList = replaceFirst!(cap => to!string(to!int(cap.hit)+1))
(list, regex(`[0-9]+`));
Expand Down Expand Up @@ -1577,7 +1577,7 @@ public Splitter!(keepSeparators, Range, RegEx) splitter(
///
unittest
{
import std.algorithm: equal;
import std.algorithm : equal;
auto s1 = ", abc, de, fg, hi, ";
assert(equal(splitter(s1, regex(", *")),
["", "abc", "de", "fg", "hi", ""]));
Expand Down
2 changes: 1 addition & 1 deletion std/socket.d
Original file line number Diff line number Diff line change
Expand Up @@ -2027,7 +2027,7 @@ static if (is(sockaddr_un))
unittest
{
import core.stdc.stdio : remove;
import std.file: deleteme;
import std.file : deleteme;

immutable ubyte[] data = [1, 2, 3, 4];
Socket[2] pair;
Expand Down
4 changes: 2 additions & 2 deletions std/stdio.d
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ Throws: $(D Exception) if the file is not opened or if the call to $(D fflush) f
{
// Issue 12349
static import std.file;
import std.exception: assertThrown;
import std.exception : assertThrown;

auto deleteme = testFilename();
auto f = File(deleteme, "w");
Expand Down Expand Up @@ -3080,7 +3080,7 @@ unittest

@safe unittest
{
import std.exception: collectException;
import std.exception : collectException;
auto e = collectException({ File f; f.writeln("Hello!"); }());
assert(e && e.msg == "Attempting to write to closed File");
}
Expand Down
8 changes: 4 additions & 4 deletions std/string.d
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@ private ptrdiff_t indexOfAnyNeitherImpl(bool forward, bool any, Char, Char2)(
}
else
{
import std.uni: toLower;
import std.uni : toLower;
if (needles.length <= 16 && needles.walkLength(17))
{
size_t si = 0;
Expand Down Expand Up @@ -2287,7 +2287,7 @@ S capitalize(S)(S input) @trusted pure
if (isSomeString!S)
{
import std.uni : asCapitalized;
import std.conv: to;
import std.conv : to;
import std.array;

return input.asCapitalized.array.to!S;
Expand Down Expand Up @@ -6356,7 +6356,7 @@ size_t column(Range)(Range str, in size_t tabsize = 8)
static if (is(Unqual!(ElementEncodingType!Range) == char))
{
// decoding needed for chars
import std.utf: byDchar;
import std.utf : byDchar;

return str.byDchar.column(tabsize);
}
Expand Down Expand Up @@ -6477,7 +6477,7 @@ unittest
S wrap(S)(S s, in size_t columns = 80, S firstindent = null,
S indent = null, in size_t tabsize = 8) if (isSomeString!S)
{
import std.uni: isWhite;
import std.uni : isWhite;
typeof(s.dup) result;
bool inword;
bool first = true;
Expand Down
22 changes: 11 additions & 11 deletions std/typecons.d
Original file line number Diff line number Diff line change
Expand Up @@ -2075,7 +2075,7 @@ Returns:
///
unittest
{
import std.exception: assertThrown, assertNotThrown;
import std.exception : assertThrown, assertNotThrown;

Nullable!int ni;
//`get` is implicitly called. Will throw
Expand Down Expand Up @@ -2371,7 +2371,7 @@ unittest
}
unittest
{
import std.conv: to;
import std.conv : to;
import std.array;

// Bugzilla 10915
Expand Down Expand Up @@ -2556,7 +2556,7 @@ Returns:
///
unittest
{
import std.exception: assertThrown, assertNotThrown;
import std.exception : assertThrown, assertNotThrown;

Nullable!(int, -1) ni;
//`get` is implicitly called. Will throw
Expand Down Expand Up @@ -2695,7 +2695,7 @@ unittest
}
unittest
{
import std.conv: to;
import std.conv : to;

// Bugzilla 10915
Nullable!(int, 1) ni = 1;
Expand Down Expand Up @@ -2851,7 +2851,7 @@ Params:
///
unittest
{
import std.exception: assertThrown, assertNotThrown;
import std.exception : assertThrown, assertNotThrown;

NullableRef!int nr;
assert(nr.isNull);
Expand All @@ -2877,7 +2877,7 @@ This function is also called for the implicit conversion to $(D T).
///
unittest
{
import std.exception: assertThrown, assertNotThrown;
import std.exception : assertThrown, assertNotThrown;

NullableRef!int nr;
//`get` is implicitly called. Will throw
Expand Down Expand Up @@ -2997,7 +2997,7 @@ unittest
}
unittest
{
import std.conv: to;
import std.conv : to;

// Bugzilla 10915
NullableRef!int nri;
Expand Down Expand Up @@ -3051,7 +3051,7 @@ alias BlackHole(Base) = AutoImplement!(Base, generateEmptyFunction, isAbstractFu
///
unittest
{
import std.math: isNaN;
import std.math : isNaN;

static abstract class C
{
Expand Down Expand Up @@ -3131,7 +3131,7 @@ alias WhiteHole(Base) = AutoImplement!(Base, generateAssertTrap, isAbstractFunct
///
unittest
{
import std.exception: assertThrown;
import std.exception : assertThrown;

static class C
{
Expand Down Expand Up @@ -5878,8 +5878,8 @@ template TypedefType(T)
///
unittest
{
import std.typecons: Typedef, TypedefType;
import std.conv: to;
import std.typecons : Typedef, TypedefType;
import std.conv : to;

alias MyInt = Typedef!int;
static assert(is(TypedefType!MyInt == int));
Expand Down
4 changes: 2 additions & 2 deletions std/uni.d
Original file line number Diff line number Diff line change
Expand Up @@ -8311,7 +8311,7 @@ unittest
{
}

import std.algorithm.comparison : equal;
import std.algorithm.comparison : equal;

"HELLo"w.asLowerCase.equal("hello"d);
"HELLo"w.asUpperCase.equal("HELLO"d);
Expand Down Expand Up @@ -8516,7 +8516,7 @@ unittest
{
}

import std.algorithm.comparison : equal;
import std.algorithm.comparison : equal;

"HELLo"w.asCapitalized.equal("Hello"d);
"hElLO"w.asCapitalized.equal("Hello"d);
Expand Down
2 changes: 1 addition & 1 deletion std/utf.d
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ unittest

unittest // invalid start bytes
{
import std.exception: assertThrown;
import std.exception : assertThrown;
immutable char[] invalidStartBytes = [
0b1111_1000, // indicating a sequence length of 5
0b1111_1100, // 6
Expand Down
6 changes: 3 additions & 3 deletions std/uuid.d
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ public struct UUID
*/
@trusted pure nothrow string toString() const
{
import std.exception: assumeUnique;
import std.exception : assumeUnique;
auto result = new char[36];
toString(result);
return result.assumeUnique;
Expand All @@ -913,7 +913,7 @@ public struct UUID

@safe pure nothrow @nogc unittest
{
import std.meta: AliasSeq;
import std.meta : AliasSeq;
foreach (Char; AliasSeq!(char, wchar, dchar))
{
alias String = immutable(Char)[];
Expand All @@ -934,7 +934,7 @@ public struct UUID

pure nothrow @nogc unittest
{
import std.encoding: Char = AsciiChar;
import std.encoding : Char = AsciiChar;
enum utfstr = "8ab3060e-2cba-4f23-b74c-b52db3bdfb46";
alias String = immutable(Char)[];
enum String s = cast(String)utfstr;
Expand Down
4 changes: 2 additions & 2 deletions std/zip.d
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ void main(string[] args)
}
// Create and write new zip file.
import std.file: write;
import std.string: representation;
import std.file : write;
import std.string : representation;
void main()
{
Expand Down
8 changes: 4 additions & 4 deletions std/zlib.d
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
* -------
* import std.zlib;
* import std.stdio;
* import std.conv: to;
* import std.algorithm: map;
* import std.conv : to;
* import std.algorithm : map;
*
* UnCompress decmp = new UnCompress;
* foreach (chunk; stdin.byChunk(4096).map!(x => decmp.uncompress(x)))
Expand Down Expand Up @@ -334,7 +334,7 @@ enum HeaderFormat {

class Compress
{
import std.conv: to;
import std.conv : to;

private:
z_stream zs;
Expand Down Expand Up @@ -511,7 +511,7 @@ class Compress

class UnCompress
{
import std.conv: to;
import std.conv : to;

private:
z_stream zs;
Expand Down