diff --git a/std/stdio.d b/std/stdio.d index b0d96f2d54a..ae28814390d 100644 --- a/std/stdio.d +++ b/std/stdio.d @@ -2409,7 +2409,7 @@ void main() private struct ByLineCopy(Char, Terminator) { private: - import std.typecons : SafeRefCounted, RefCountedAutoInitialize; + import std.typecons : borrow, RefCountedAutoInitialize, SafeRefCounted; /* Ref-counting stops the source range's ByLineCopyImpl * from getting out of sync after the range is copied, e.g. @@ -2425,19 +2425,19 @@ void main() impl = Impl(f, kt, terminator); } - @property bool empty() + @property bool empty() @safe { - return impl.refCountedPayload.empty; + return impl.borrow!(i => i.empty); } - @property Char[] front() + @property Char[] front() @safe { - return impl.refCountedPayload.front; + return impl.borrow!(i => i.front); } - void popFront() + void popFront() @safe { - impl.refCountedPayload.popFront(); + impl.borrow!(i => i.popFront()); } } @@ -2666,7 +2666,7 @@ $(REF readText, std,file) assert(!file.isOpen); } - @system unittest + @safe unittest { static import std.file; auto deleteme = testFilename(); @@ -4750,15 +4750,9 @@ struct lines foreach (string line; myLines) continue; - auto myByLineCopy = f.byLineCopy; // but cannot safely iterate yet - /* - still `@system`: - - cannot call `@system` function `std.stdio.File.ByLineCopy!(immutable(char), char).ByLineCopy.empty` - - cannot call `@system` function `std.stdio.File.ByLineCopy!(immutable(char), char).ByLineCopy.popFront` - - cannot call `@system` function `std.stdio.File.ByLineCopy!(immutable(char), char).ByLineCopy.front` - */ - //foreach (line; myByLineCopy) - // continue; + auto myByLineCopy = f.byLineCopy; + foreach (line; myByLineCopy) + continue; } }