I can't seem to find a way of splitting a range of characters into lines unless the range has a length or can be sliced? This presumably is because i is a range of chunks, which cannot have a length or a slice. I do not see how to get anything else from the File object at the moment.

import std.stdio;
import std.string;

void printFile(Range)(Range i)
{
    foreach (l; lineSplitter(i)) {
        writefln("%d\n", l);
    }
}

auto range(File f)
{
    const size_t someArbitrary = 4096;
    return f.byChunk(someArbitrary);
}

void main()
{
    File f = File("/etc/passwd");

    printFile(f.range());
// std.string.lineSplitter(Flag keepTerm = KeepTerminator.no, Range)(Range r) if (hasSlicing!Range && hasLength!Range || isSomeString!Range) // test.d(21): Error: template instance test.printFile!(ByChunk) error instantiating
}

Reply via email to