const auto x = "abacc";
{
string y = x;
const bool ok = y.findLastSkip("_");
assert(!ok);
assert(y is x);
}
{
string y = x;
const bool ok = y.findLastSkip("a");
assert(ok);
assert(y == x[3 .. $]);
}
{
string y = x;
const bool ok = y.findLastSkip("c");
assert(ok);
assert(y is x[$ .. $]);
}
version (unittest) {
static char[] f()() @safe pure nothrow { char[1] x = "_"; return x[].findLastSkip(" "); }
static if (hasPreviewDIP1000) static assert(!__traits(compiles, { auto _ = f(); }));
}
const auto x = "abacc";
{
string y = x;
const bool ok = y.findLastSkip('_');
assert(!ok);
assert(y is x);
}
{
string y = x;
const bool ok = y.findLastSkip('a');
assert(ok);
assert(y == x[3 .. $]);
}
{
string y = x;
const bool ok = y.findLastSkip('c');
assert(ok);
assert(y is x[$ .. $]);
}
version (unittest) {
static char[] f()() @safe pure nothrow { char[1] x = "_"; return x[].findLastSkip(' '); }
static if (hasPreviewDIP1000) static assert(!__traits(compiles, { auto _ = f(); }));
}