A small example showing this strange behaviour:
import std.stdio; import std.algorithm.iteration; import std.range;enum BUFFER_SIZE = 1024; void main(string[] args) { auto a = (new File(args[1])) .byChunk(BUFFER_SIZE) .joiner; writeln(a.take(5)); writeln(a); }
Using a file, containing the bytes 1 to 10 I get:
[ 1, 2, 3, 4, 5 ] [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
take does not consume. When I now change BUFFER_SIZE to 2 I get:
[ 1, 2, 3, 4, 5 ] [ 5, 6, 7, 8, 9, 10 ]
Now the first two buffers have been consumend and the third ([5, 6]) not.
Feels like a bug in Phobos. But maybe I do not understand, what's happening and this is correct behaviour. Can anyone explain or confirm, that this is a bug?
