mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
use lent for the return value of index accesses of tables (#22812)
ref https://forum.nim-lang.org/t/10525
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user