From 0be71677d99511c210d7ff62e642dcb32956ed5d Mon Sep 17 00:00:00 2001 From: Araq Date: Fri, 20 Oct 2017 17:23:36 +0200 Subject: [PATCH] macros.nim: added missing pairs iterator --- lib/core/macros.nim | 5 +++++ 1 file changed, 5 insertions(+) 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: