Skip to content

Commit 123e6e7

Browse files
authored
[std.range.iota] Improve in operator docs (#10868)
1 parent b1bb234 commit 123e6e7

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

std/algorithm/comparison.d

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,12 @@ Returns:
8282
found value plus one is returned.
8383
8484
See_Also:
85-
$(REF_ALTTEXT find, find, std,algorithm,searching) and $(REF_ALTTEXT canFind, canFind, std,algorithm,searching) for finding a value in a
86-
range.
85+
$(UL
86+
$(LI $(REF_SHORT find, std,algorithm,searching) and
87+
$(REF_SHORT canFind, std,algorithm,searching) for finding a value in a range.)
88+
$(LI $(REF_ALTTEXT `value in iota(start, end)`, iota, std,range) to find a value in
89+
a particular interval.)
90+
)
8791
*/
8892
uint among(alias pred = (a, b) => a == b, Value, Values...)
8993
(Value value, Values values)

std/range/package.d

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6847,12 +6847,15 @@ pure @safe nothrow unittest
68476847
user-defined types that support `++`, the range is an input
68486848
range.
68496849
6850-
An integral iota also supports `in` operator from the right. It takes
6851-
the stepping into account, the integral won't be considered
6852-
contained if it falls between two consecutive values of the range.
6853-
`contains` does the same as in, but from lefthand side.
6850+
$(DDOC_SECTION_H `in` operator and `contains`:)
6851+
`iota` over an integral/pointer type defines the `in` operator from the right.
6852+
`val in iota(...)` is true when `val` occurs in the range. When present, it takes
6853+
`step` into account - `val` won't be considered
6854+
contained if it falls between two consecutive elements of the range.
6855+
The `contains` method does the same as `in`, but from the left-hand side.
68546856
68556857
Example:
6858+
$(RUNNABLE_EXAMPLE
68566859
---
68576860
void main()
68586861
{
@@ -6879,6 +6882,7 @@ pure @safe nothrow unittest
68796882
writeln();
68806883
}
68816884
---
6885+
)
68826886
*/
68836887
auto iota(B, E, S)(B begin, E end, S step)
68846888
if ((isIntegral!(CommonType!(B, E)) || isPointer!(CommonType!(B, E)))

0 commit comments

Comments
 (0)