Unary predicate for determining when to stop counting.
The input range to be counted.
- The number of elements which must be popped from the front of haystack before reaching an element for which startsWith!pred(haystack) is true. - If startsWith!pred(haystack) is not true for any element in haystack, then -1 is returned.
import std.ascii : isDigit; import std.uni : isWhite; assert(countUntil!(isWhite)("hello world") == 5); assert(countUntil!(isDigit)("hello world") == -1); assert(countUntil!"a > 20"([0, 7, 12, 22, 9]) == 3);
Counts elements in the given input range until the given predicate is true for one of the elements of haystack.