summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authoree7 <45465154+ee7@users.noreply.github.com>2020-07-06 14:02:03 +0200
committerGitHub <noreply@github.com>2020-07-06 14:02:03 +0200
commita754160d654f03584088412f51b153ae6a170adb (patch)
treef3263ac6c39acdb2ee188b39f167a0457f4607e8 /lib
parent65af99a203387882d9fba7d94ae0cd46f479dd1f (diff)
downloadNim-a754160d654f03584088412f51b153ae6a170adb.tar.gz
tables.nim: Add named fields in `smallest` and `largest` (#14919)
The `smallest` and `largest` procs for `CountTable` returned a tuple
with named fields, but the same procs for `CountTableRef` returned an
anonymous tuple.

This commit makes those `CountTableRef` procs more consistent, and adds
a test.

Fixes: #14918
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/collections/tables.nim4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim
index 2ea58ce1f..a969a4c5d 100644
--- a/lib/pure/collections/tables.nim
+++ b/lib/pure/collections/tables.nim
@@ -2670,14 +2670,14 @@ proc inc*[A](t: CountTableRef[A], key: A, val = 1) =
     doAssert a == newCountTable("aaabbbbbbbbbbb")
   t[].inc(key, val)
 
-proc smallest*[A](t: CountTableRef[A]): (A, int) =
+proc smallest*[A](t: CountTableRef[A]): tuple[key: A, val: int] =
   ## Returns the ``(key, value)`` pair with the smallest ``val``. Efficiency: O(n)
   ##
   ## See also:
   ## * `largest proc<#largest,CountTableRef[A]>`_
   t[].smallest
 
-proc largest*[A](t: CountTableRef[A]): (A, int) =
+proc largest*[A](t: CountTableRef[A]): tuple[key: A, val: int] =
   ## Returns the ``(key, value)`` pair with the largest ``val``. Efficiency: O(n)
   ##
   ## See also: