@@ -2409,7 +2409,7 @@ void main()
24092409 private struct ByLineCopy (Char, Terminator)
24102410 {
24112411 private :
2412- import std.typecons : SafeRefCounted , RefCountedAutoInitialize;
2412+ import std.typecons : borrow , RefCountedAutoInitialize, SafeRefCounted ;
24132413
24142414 /* Ref-counting stops the source range's ByLineCopyImpl
24152415 * from getting out of sync after the range is copied, e.g.
@@ -2425,19 +2425,19 @@ void main()
24252425 impl = Impl(f, kt, terminator);
24262426 }
24272427
2428- @property bool empty()
2428+ @property bool empty() @safe
24292429 {
2430- return impl.refCountedPayload .empty;
2430+ return impl.borrow ! (i => i .empty) ;
24312431 }
24322432
2433- @property Char[] front()
2433+ @property Char[] front() @safe
24342434 {
2435- return impl.refCountedPayload .front;
2435+ return impl.borrow ! (i => i .front) ;
24362436 }
24372437
2438- void popFront ()
2438+ void popFront () @safe
24392439 {
2440- impl.refCountedPayload .popFront();
2440+ impl.borrow ! (( ref i) => i .popFront() );
24412441 }
24422442 }
24432443
@@ -2666,7 +2666,7 @@ $(REF readText, std,file)
26662666 assert (! file.isOpen);
26672667 }
26682668
2669- @system unittest
2669+ @safe unittest
26702670 {
26712671 static import std.file ;
26722672 auto deleteme = testFilename();
@@ -4749,16 +4749,16 @@ struct lines
47494749 auto myLines = lines(f);
47504750 foreach (string line; myLines)
47514751 continue ;
4752+ }
4753+
47524754
4753- auto myByLineCopy = f.byLineCopy; // but cannot safely iterate yet
4754- /*
4755- still `@system`:
4756- - cannot call `@system` function `std.stdio.File.ByLineCopy!(immutable(char), char).ByLineCopy.empty`
4757- - cannot call `@system` function `std.stdio.File.ByLineCopy!(immutable(char), char).ByLineCopy.popFront`
4758- - cannot call `@system` function `std.stdio.File.ByLineCopy!(immutable(char), char).ByLineCopy.front`
4759- */
4760- // foreach (line; myByLineCopy)
4761- // continue;
4755+ {
4756+ auto f = File (deleteMe, " r" );
4757+ scope (exit) { f.close(); }
4758+
4759+ auto myByLineCopy = f.byLineCopy;
4760+ foreach (line; myByLineCopy)
4761+ continue ;
47624762 }
47634763}
47644764
0 commit comments