1-- Traversal: the concept a `for` loop walks a value through ([1320]). A
2-- `for x in s` over a struct or an `any C` takes `s`'s conformance to this
3-- `iterable`, and to no other concept of that name (D1957).
4
5--- What `for x in s` walks. A conformance supplies the cursor type `cur`
6--- and the type of the items handed out, `item_type`, and the four entries:
7--- `first` gives the cursor of the first item, `at_end` says whether a
8--- cursor is past the last, `item` hands out the item at a cursor as a
9--- fresh value, never a view of the source, and `next` gives the cursor
10--- after it. Each entry gets a read-only pointer to the loop's own copy of
11--- the source. The signatures are exact: no permission, error set or
12--- `from` clause is inferred or converted. A container whose items are one
13--- slice hands out the slice instead, which `for` walks directly.
14public iterable: type = concept (t: type, cur: type, item_type: type)
15 --- The cursor of the first item, or one `at_end` already.
16 first: (s: ptr t) -> (c: cur)
17 --- Whether `c` is past the last item.
18 at_end: (s: ptr t, c: cur) -> (yes: bool)
19 --- The item at `c`, a value of its own.
20 item: (s: ptr t, c: cur) -> (v: item_type)
21 --- The cursor after `c`.
22 next: (s: ptr t, c: cur) -> (c2: cur)
23end iterable