chomp

Undocumented in source. Be warned that the author may not have intended to support it.
  1. inout(T)[] chomp(inout(T)[] haystack, T[] needle)
  2. inout(T)[] chomp(inout(T)[] haystack, T needle)
    @trusted
    inout(T)[]
    chomp
    (
    T
    )
    (
    scope return inout(T)[] haystack
    ,
    in T needle
    )
  3. bool startsWith(T[] haystack, T[] needle)
  4. bool startsWith(T[] haystack, T needle)

Examples

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(); }));
}

Meta