import std.algorithm.comparison : equal; import std.algorithm.comparison : among; import nxt.array_help : s; assert(``.splitterASCII!(_ => _ == ' ') .empty); assert(` `.splitterASCII!(_ => _ == ' ') .empty); assert(` `.splitterASCII!(_ => _ == ' ') .empty); assert(` - `.splitterASCII!(_ => _ == ' ') .equal([`-`].s[])); assert(`a`.splitterASCII!(_ => _ == ' ') .equal([`a`].s[])); assert(` a `.splitterASCII!(_ => _ == ' ') .equal([`a`].s[])); assert(` a b `.splitterASCII!(_ => _ == ' ') .equal([`a`, `b`].s[])); assert(` a_b `.splitterASCII!(_ => _ == ' ') .equal([`a_b`].s[])); assert(` - aa bb--c-_d--_e`.splitterASCII!(_ => _.among!(' ', '-', '_') != 0) .equal([`aa`, `bb`, `c`, `d`, `e`].s[]));
DIP-1000 return ref escape analysis
import nxt.dip_traits : hasPreviewDIP1000; version (none) // TODO: enable static if (hasPreviewDIP1000) { // See_Also: https://forum.dlang.org/post/pzddsrwhfvcopfaamvak@forum.dlang.org static assert(!__traits(compiles, { char[] f() { char[2] x; return x[].splitterASCII!(_ => _ == ' ').front; } } )); }
Non-decoding ASCII-separator-only variant of Phobos' splitter.