assert(chompPrefix("hello world", "he") == "llo world"); assert(chompPrefix("hello world", "hello w") == "orld"); assert(chompPrefix("hello world", " world") == "hello world"); assert(chompPrefix("", "hello") == ""); version (unittest) { static char[] f()() @safe pure nothrow { char[1] x = "_"; return x[].chompPrefix(" "); } static if (hasPreviewDIP1000) static assert(!__traits(compiles, { auto _ = f(); })); }