Skip to content

Commit c791aa6

Browse files
committed
Issue 10832: document countUntil footgun.
1 parent d9b9f77 commit c791aa6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

std/algorithm/searching.d

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,11 @@ if (isInputRange!R && !isInfinite!R)
807807
- `needle` is the index into `needles` which matched.
808808
- Both are `-1` if there was no match.
809809
810+
Warning: Due to the auto-decoding, the return value of this function may
811+
$(I not) correspond to the array index of strings. To find the index of an
812+
element matching the predicate in strings, use $(REF indexOf, std,string)
813+
instead.
814+
810815
See_Also: $(REF indexOf, std,string)
811816
+/
812817
auto countUntil(alias pred = "a == b", R, Rs...)(R haystack, Rs needles)
@@ -1046,6 +1051,11 @@ if (isInputRange!R &&
10461051
$(LREF startsWith)`!pred(haystack)` is `true`.
10471052
- If `startsWith!pred(haystack)` is not `true` for any element in
10481053
`haystack`, then `-1` is returned.
1054+
1055+
Warning: Due to the auto-decoding, the return value of this function may
1056+
$(I not) correspond to the array index of strings. To find the index of an
1057+
element matching the predicate in strings, use $(REF indexOf, std,string)
1058+
instead.
10491059
+/
10501060
ptrdiff_t countUntil(alias pred, R)(R haystack)
10511061
if (isInputRange!R &&

0 commit comments

Comments
 (0)