@@ -281,7 +281,7 @@ proc initTable*[A, B](initialSize = defaultInitialSize): Table[A, B] =
281
281
result = default (Table [A, B])
282
282
initImpl (result , initialSize)
283
283
284
- proc `[]=` * [A, B](t: var Table [A, B], key: A, val: sink B) =
284
+ proc `[]=` * [A, B](t: var Table [A, B], key: sink A, val: sink B) =
285
285
# # Inserts a `(key, value)` pair into `t`.
286
286
# #
287
287
# # See also:
@@ -313,7 +313,7 @@ proc toTable*[A, B](pairs: openArray[(A, B)]): Table[A, B] =
313
313
result = initTable [A, B](pairs.len)
314
314
for key, val in items (pairs): result [key] = val
315
315
316
- proc `[]` * [A, B](t: Table [A, B], key: A): lent B =
316
+ proc `[]` * [A, B](t: Table [A, B], key: sink A): lent B =
317
317
# # Retrieves the value at `t[key]`.
318
318
# #
319
319
# # If `key` is not in `t`, the `KeyError` exception is raised.
@@ -336,7 +336,7 @@ proc `[]`*[A, B](t: Table[A, B], key: A): lent B =
336
336
echo a['z' ]
337
337
get (t, key)
338
338
339
- proc `[]` * [A, B](t: var Table [A, B], key: A): var B =
339
+ proc `[]` * [A, B](t: var Table [A, B], key: sink A): var B =
340
340
# # Retrieves the value at `t[key]`. The value can be modified.
341
341
# #
342
342
# # If `key` is not in `t`, the `KeyError` exception is raised.
@@ -494,7 +494,7 @@ proc len*[A, B](t: Table[A, B]): int =
494
494
495
495
result = t.counter
496
496
497
- proc add * [A, B](t: var Table [A, B], key: A, val: sink B) {.deprecated :
497
+ proc add * [A, B](t: var Table [A, B], key: sink A, val: sink B) {.deprecated :
498
498
" Deprecated since v1.4; it was more confusing than useful, use `[]=`" .} =
499
499
# # Puts a new `(key, value)` pair into `t` even if `t[key]` already exists.
500
500
# #
@@ -864,7 +864,7 @@ proc newTableFrom*[A, B, C](collection: A, index: proc(x: B): C): TableRef[C, B]
864
864
for item in collection:
865
865
result [index (item)] = item
866
866
867
- proc `[]` * [A, B](t: TableRef [A, B], key: A): var B =
867
+ proc `[]` * [A, B](t: TableRef [A, B], key: sink A): var B =
868
868
# # Retrieves the value at `t[key]`.
869
869
# #
870
870
# # If `key` is not in `t`, the `KeyError` exception is raised.
@@ -888,7 +888,7 @@ proc `[]`*[A, B](t: TableRef[A, B], key: A): var B =
888
888
889
889
result = t[][key]
890
890
891
- proc `[]=` * [A, B](t: TableRef [A, B], key: A, val: sink B) =
891
+ proc `[]=` * [A, B](t: TableRef [A, B], key: sink A, val: sink B) =
892
892
# # Inserts a `(key, value)` pair into `t`.
893
893
# #
894
894
# # See also:
@@ -1045,7 +1045,7 @@ proc len*[A, B](t: TableRef[A, B]): int =
1045
1045
1046
1046
result = t.counter
1047
1047
1048
- proc add * [A, B](t: TableRef [A, B], key: A, val: sink B) {.deprecated :
1048
+ proc add * [A, B](t: TableRef [A, B], key: sink A, val: sink B) {.deprecated :
1049
1049
" Deprecated since v1.4; it was more confusing than useful, use `[]=`" .} =
1050
1050
# # Puts a new `(key, value)` pair into `t` even if `t[key]` already exists.
1051
1051
# #
@@ -1297,7 +1297,7 @@ proc rawGet[A, B](t: OrderedTable[A, B], key: A, hc: var Hash): int =
1297
1297
1298
1298
proc rawInsert [A, B](t: var OrderedTable [A, B],
1299
1299
data: var OrderedKeyValuePairSeq [A, B],
1300
- key: A, val: sink B, hc: Hash , h: Hash ) =
1300
+ key: sink A, val: sink B, hc: Hash , h: Hash ) =
1301
1301
rawInsertImpl ()
1302
1302
data[h].next = - 1
1303
1303
if t.first < 0 : t.first = h
@@ -1349,7 +1349,7 @@ proc initOrderedTable*[A, B](initialSize = defaultInitialSize): OrderedTable[A,
1349
1349
result = default (OrderedTable [A, B])
1350
1350
initImpl (result , initialSize)
1351
1351
1352
- proc `[]=` * [A, B](t: var OrderedTable [A, B], key: A, val: sink B) =
1352
+ proc `[]=` * [A, B](t: var OrderedTable [A, B], key: sink A, val: sink B) =
1353
1353
# # Inserts a `(key, value)` pair into `t`.
1354
1354
# #
1355
1355
# # See also:
@@ -1382,7 +1382,7 @@ proc toOrderedTable*[A, B](pairs: openArray[(A, B)]): OrderedTable[A, B] =
1382
1382
result = initOrderedTable [A, B](pairs.len)
1383
1383
for key, val in items (pairs): result [key] = val
1384
1384
1385
- proc `[]` * [A, B](t: OrderedTable [A, B], key: A): lent B =
1385
+ proc `[]` * [A, B](t: OrderedTable [A, B], key: sink A): lent B =
1386
1386
# # Retrieves the value at `t[key]`.
1387
1387
# #
1388
1388
# # If `key` is not in `t`, the `KeyError` exception is raised.
@@ -1406,7 +1406,7 @@ proc `[]`*[A, B](t: OrderedTable[A, B], key: A): lent B =
1406
1406
1407
1407
get (t, key)
1408
1408
1409
- proc `[]` * [A, B](t: var OrderedTable [A, B], key: A): var B =
1409
+ proc `[]` * [A, B](t: var OrderedTable [A, B], key: sink A): var B =
1410
1410
# # Retrieves the value at `t[key]`. The value can be modified.
1411
1411
# #
1412
1412
# # If `key` is not in `t`, the `KeyError` exception is raised.
@@ -1547,7 +1547,7 @@ proc len*[A, B](t: OrderedTable[A, B]): int {.inline.} =
1547
1547
1548
1548
result = t.counter
1549
1549
1550
- proc add * [A, B](t: var OrderedTable [A, B], key: A, val: sink B) {.deprecated :
1550
+ proc add * [A, B](t: var OrderedTable [A, B], key: sink A, val: sink B) {.deprecated :
1551
1551
" Deprecated since v1.4; it was more confusing than useful, use `[]=`" .} =
1552
1552
# # Puts a new `(key, value)` pair into `t` even if `t[key]` already exists.
1553
1553
# #
@@ -1884,7 +1884,7 @@ proc newOrderedTable*[A, B](pairs: openArray[(A, B)]): OrderedTableRef[A, B] =
1884
1884
for key, val in items (pairs): result [key] = val
1885
1885
1886
1886
1887
- proc `[]` * [A, B](t: OrderedTableRef [A, B], key: A): var B =
1887
+ proc `[]` * [A, B](t: OrderedTableRef [A, B], key: sink A): var B =
1888
1888
# # Retrieves the value at `t[key]`.
1889
1889
# #
1890
1890
# # If `key` is not in `t`, the `KeyError` exception is raised.
@@ -1907,7 +1907,7 @@ proc `[]`*[A, B](t: OrderedTableRef[A, B], key: A): var B =
1907
1907
echo a['z' ]
1908
1908
result = t[][key]
1909
1909
1910
- proc `[]=` * [A, B](t: OrderedTableRef [A, B], key: A, val: sink B) =
1910
+ proc `[]=` * [A, B](t: OrderedTableRef [A, B], key: sink A, val: sink B) =
1911
1911
# # Inserts a `(key, value)` pair into `t`.
1912
1912
# #
1913
1913
# # See also:
@@ -2048,7 +2048,7 @@ proc len*[A, B](t: OrderedTableRef[A, B]): int {.inline.} =
2048
2048
2049
2049
result = t.counter
2050
2050
2051
- proc add * [A, B](t: OrderedTableRef [A, B], key: A, val: sink B) {.deprecated :
2051
+ proc add * [A, B](t: OrderedTableRef [A, B], key: sink A, val: sink B) {.deprecated :
2052
2052
" Deprecated since v1.4; it was more confusing than useful, use `[]=`" .} =
2053
2053
# # Puts a new `(key, value)` pair into `t` even if `t[key]` already exists.
2054
2054
# #
@@ -2345,7 +2345,7 @@ proc toCountTable*[A](keys: openArray[A]): CountTable[A] =
2345
2345
result = initCountTable [A](keys.len)
2346
2346
for key in items (keys): result .inc (key)
2347
2347
2348
- proc `[]` * [A](t: CountTable [A], key: A): int =
2348
+ proc `[]` * [A](t: CountTable [A], key: sink A): int =
2349
2349
# # Retrieves the value at `t[key]` if `key` is in `t`.
2350
2350
# # Otherwise `0` is returned.
2351
2351
# #
@@ -2703,7 +2703,7 @@ proc newCountTable*[A](keys: openArray[A]): CountTableRef[A] =
2703
2703
{.noSideEffect .}:
2704
2704
for key in items (keys): result .inc (key)
2705
2705
2706
- proc `[]` * [A](t: CountTableRef [A], key: A): int =
2706
+ proc `[]` * [A](t: CountTableRef [A], key: sink A): int =
2707
2707
# # Retrieves the value at `t[key]` if `key` is in `t`.
2708
2708
# # Otherwise `0` is returned.
2709
2709
# #
0 commit comments