From c274e67198e446f07708c0a14751da3b2832cec9 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Tue, 23 Feb 2021 11:25:35 -0800 Subject: add enumutils.items for sparse enums, typetraits.SomeSparseEnum (#17080) * add enumutils.items for enum with holes * changelog * ref in lib.rst * use `type SomeSparseEnum* = (not Ordinal) and enum` instead of concept * address comment: rename back to enum with holes --- lib/system/iterators.nim | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/system/iterators.nim') diff --git a/lib/system/iterators.nim b/lib/system/iterators.nim index 504695bf6..7f0076a44 100644 --- a/lib/system/iterators.nim +++ b/lib/system/iterators.nim @@ -82,8 +82,13 @@ iterator mitems*(a: var cstring): var char {.inline.} = yield a[i] inc(i) -iterator items*[T: enum](E: typedesc[T]): T = - ## Iterates over the values of the enum ``E``. +iterator items*[T: enum and Ordinal](E: typedesc[T]): T = + ## Iterates over the values of `E`. + ## See also `enumutils.items` for enums with holes. + runnableExamples: + type Goo = enum g0 = 2, g1, g2 + from std/sequtils import toSeq + assert Goo.toSeq == [g0, g1, g2] for v in low(E) .. high(E): yield v -- cgit 1.4.1-2-gfad0 cf1425eb996db5d39a23c0360573f1addd4a850'>refs log tree commit diff stats
path: root/doc/overview.txt
blob: 2420390860c124d86dc754e7c27c74d1f26ef228 (plain) (blame)
1
2
3
4
5
6
7
8
9