June 09, 2021

I want add Yes.keepTerminator flag on lineSplitter.

June 09, 2021
On 6/9/21 2:48 PM, Marcone wrote:
> I want add Yes.keepTerminator flag on lineSplitter.

It's a template parameter, which is specified after an exclamation mark. The trouble is, Flag is defined in std.typecons. I would expect std.typecons (or at least Flag from it) to be publicly imported but it is not. I think that is an interface bug: If it appears in the interface (of lineSplitter), it should be available without needing to import additional modules.

import std.string;
import std.stdio;
import std.typecons;

void main() {
  auto input = "line1\nline2\nline3";
  auto range = input.lineSplitter!(Yes.keepTerminator);
  writeln(range);
}

Ali