diff options
Diffstat (limited to 'src/utils.nim')
-rw-r--r-- | src/utils.nim | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/utils.nim b/src/utils.nim index 8316110..288cf44 100644 --- a/src/utils.nim +++ b/src/utils.nim @@ -67,9 +67,13 @@ iterator enumerate*[T: enum]: T = for i in elow .. ehigh: yield T(i) -iterator namedPairs*[K, V](table: Table[K, V]): tuple[key: K, value: V] = - for key, value in table.pairs: - yield (key, value) +template namedPairsTyped(T: typedesc) = + iterator namedPairs*[K, V](table: T[K, V]): tuple[key: K, value: V] = + for key, value in table.pairs: + yield (key, value) + +namedPairsTyped(Table) +namedPairsTyped(OrderedTable) iterator reversed*[T](s: openArray[T]): T = for i in countdown(s.len - 1, 0): |