Skip to content

Commit

Permalink
add effectsOf to std/tables (nim-lang#20751)
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout authored and capocasa committed Mar 31, 2023
1 parent e859508 commit cb1885b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/pure/collections/tables.nim
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ runnableExamples:
import std/private/since
import hashes, math, algorithm


when not defined(nimHasEffectsOf):
{.pragma: effectsOf.}

type
KeyValuePair[A, B] = tuple[hcode: Hash, key: A, val: B]
KeyValuePairSeq[A, B] = seq[KeyValuePair[A, B]]
Expand Down Expand Up @@ -1597,7 +1601,7 @@ proc clear*[A, B](t: var OrderedTable[A, B]) =
t.last = -1

proc sort*[A, B](t: var OrderedTable[A, B], cmp: proc (x, y: (A, B)): int,
order = SortOrder.Ascending) =
order = SortOrder.Ascending) {.effectsOf: cmp.} =
## Sorts `t` according to the function `cmp`.
##
## This modifies the internal list
Expand Down Expand Up @@ -2054,7 +2058,7 @@ proc clear*[A, B](t: OrderedTableRef[A, B]) =
clear(t[])

proc sort*[A, B](t: OrderedTableRef[A, B], cmp: proc (x, y: (A, B)): int,
order = SortOrder.Ascending) =
order = SortOrder.Ascending) {.effectsOf: cmp.} =
## Sorts `t` according to the function `cmp`.
##
## This modifies the internal list
Expand Down

0 comments on commit cb1885b

Please sign in to comment.