On Sunday, 2 February 2014 at 01:03:25 UTC, Andrei Alexandrescu wrote:
On 2/1/14, 3:07 PM, Andrej Mitrovic wrote:
In reference to this thread:
http://forum.dlang.org/thread/[email protected]#post-ouyuujnzzvfkvxbfzyak:40forum.dlang.org


Personally I think it was a mistake providing unsafe APIs by default. If
I would have had it my way, I would introduce:

byLine -> safe, doesn't reuse a buffer
byLineBuffer -> reuses a buffer

No. Too much breakage.

Andrei


From the docs it appears as array() will handle the required copying.

std.array.array doc:
---
Returns a newly-allocated dynamic array consisting of a copy of the input range, static array, dynamic array, or class or struct with an opApply function r. Note that narrow strings are handled as a special case in an overload.
---

std.stdio.byLine doc:
---
Returns an input range set up to read from the file handle one line at a time.

The element type for the range will be Char[]. Range primitives may throw StdioException on I/O error.

Note:
Each front will not persist after popFront is called, so the caller must copy its contents (e.g. by calling to!string) if retention is needed.
---

Reply via email to