findSkip

Array-specialization of findSkip with default predicate.

  1. auto findSkip(inout(T)[] haystack, T[] needle)
    @trusted
    findSkip
    (
    T
    )
    (
    scope ref inout(T)[] haystack
    ,
    scope const T[] needle
    )
  2. auto findSkip(inout(T)[] haystack, T needle)

Examples

1 const auto x = "abc";
2 {
3     string y = x;
4     const bool ok = y.findSkip("_");
5     assert(!ok);
6     assert(y is x);
7 }
8 {
9     string y = x;
10     const bool ok = y.findSkip("a");
11     assert(ok);
12     assert(y == x[1 .. $]);
13 }
14 {
15     string y = x;
16     const bool ok = y.findSkip("c");
17     assert(ok);
18     assert(y is x[$ .. $]);
19 }
20 auto f()() @safe pure nothrow { char[1] x = "_"; return x[].findSkip(" "); }
21 static if (isDIP1000) static assert(!__traits(compiles, { auto _ = f(); }));
1 const auto x = "abc";
2 {
3     string y = x;
4     const bool ok = y.findSkip('_');
5     assert(!ok);
6     assert(y is x);
7 }
8 {
9     string y = x;
10     const bool ok = y.findSkip('a');
11     assert(ok);
12     assert(y == x[1 .. $]);
13 }
14 {
15     string y = x;
16     const bool ok = y.findSkip('c');
17     assert(ok);
18     assert(y is x[$ .. $]);
19 }
20 auto f()() @safe pure nothrow { char[1] x = "_"; return x[].findSkip(' '); }
21 static if (isDIP1000) static assert(!__traits(compiles, { auto _ = f(); }));

Meta