summary refs log tree commit diff stats
path: root/lib/core/macros.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2017-10-20 17:23:36 +0200
committerAraq <rumpf_a@web.de>2017-10-25 17:37:03 +0200
commit0be71677d99511c210d7ff62e642dcb32956ed5d (patch)
treecd2bcd4c2f33339bb427803291a54803d7304139 /lib/core/macros.nim
parent14e236af05985516a4ebab10c3b97dfed1d60c8e (diff)
downloadNim-0be71677d99511c210d7ff62e642dcb32956ed5d.tar.gz
macros.nim: added missing pairs iterator
Diffstat (limited to 'lib/core/macros.nim')
-rw-r--r--lib/core/macros.nim5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim
index 8c70d2b47..22c479a4a 100644
--- a/lib/core/macros.nim
+++ b/lib/core/macros.nim
@@ -986,6 +986,11 @@ iterator items*(n: NimNode): NimNode {.inline.} =
   for i in 0 ..< n.len:
     yield n[i]
 
+iterator pairs*(n: NimNode): (int, NimNode) {.inline.} =
+  ## Iterates over the children of the NimNode ``n`` and its indices.
+  for i in 0 ..< n.len:
+    yield (i, n[i])
+
 iterator children*(n: NimNode): NimNode {.inline.} =
   ## Iterates over the children of the NimNode ``n``.
   for i in 0 ..< n.len: