Skip to content

Commit 2d8ae67

Browse files
authored
Issue 10832: document countUntil footgun. (#10833)
* Issue 10832: document countUntil footgun. * Grammar. * Link to dlang tour discussion of auto-decoding.
1 parent f97b599 commit 2d8ae67

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 $(LINK2 https://tour.dlang.org/tour/en/gems/unicode,
811+
auto-decoding), the return value of this function may $(I not) correspond
812+
to the array index for strings. To find the index of an element matching
813+
the predicate in a string, use $(REF indexOf, std,string) 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 $(LINK2 https://tour.dlang.org/tour/en/gems/unicode,
1056+
auto-decoding), the return value of this function may $(I not) correspond
1057+
to the array index for strings. To find the index of an element matching
1058+
the predicate in a string, use $(REF indexOf, std,string) instead.
10491059
+/
10501060
ptrdiff_t countUntil(alias pred, R)(R haystack)
10511061
if (isInputRange!R &&

0 commit comments

Comments
 (0)