diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-10-11 21:14:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-11 15:14:12 +0200 |
commit | 9d7acd001f268e2b9dab9228ca5e22bf75028704 (patch) | |
tree | cfef44dc0c1b797a329455fc4b222ee686f15716 | |
parent | 14d25eedfd5ada29fcd3690919e40623563b98fa (diff) | |
download | Nim-9d7acd001f268e2b9dab9228ca5e22bf75028704.tar.gz |
use lent for the return value of index accesses of tables (#22812)
ref https://forum.nim-lang.org/t/10525
-rw-r--r-- | lib/pure/collections/tables.nim | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim index 39dcddb5a..6ea4a9a45 100644 --- a/lib/pure/collections/tables.nim +++ b/lib/pure/collections/tables.nim @@ -312,7 +312,7 @@ proc toTable*[A, B](pairs: openArray[(A, B)]): Table[A, B] = result = initTable[A, B](pairs.len) for key, val in items(pairs): result[key] = val -proc `[]`*[A, B](t: Table[A, B], key: A): B = +proc `[]`*[A, B](t: Table[A, B], key: A): lent B = ## Retrieves the value at `t[key]`. ## ## If `key` is not in `t`, the `KeyError` exception is raised. @@ -1357,7 +1357,7 @@ proc toOrderedTable*[A, B](pairs: openArray[(A, B)]): OrderedTable[A, B] = result = initOrderedTable[A, B](pairs.len) for key, val in items(pairs): result[key] = val -proc `[]`*[A, B](t: OrderedTable[A, B], key: A): B = +proc `[]`*[A, B](t: OrderedTable[A, B], key: A): lent B = ## Retrieves the value at `t[key]`. ## ## If `key` is not in `t`, the `KeyError` exception is raised. |