Sorting lines from standard input.
import io, std.array, std.algorithm;
void main()
{
stdin
.byLineCopy
.array
.sort()
.each!println;
}
Working with temporary files.
import io;
void main()
{
auto temp = tempFile();
println("Temporary file path: ", temp.path);
temp.file.write("Hello world!");
temp.file.position = 0;
char[5] buf;
temp.file.read(buf);
assert(buf == "Hello");
}
Using a memory map.
import io, std.parallelism, std.random;
void main()
{
auto f = File("big_random_file", FileFlags.writeNew);
f.length = 1024^^3;
auto map = f.memoryMap!size_t(Access.write);
foreach (i, ref e; parallel(map[]))
e = uniform!"[]"(size_t.min, size_t.max);
}