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