add effectsOf to map in the std/sets module (#20760)

This commit is contained in:
ringabout 2022-11-05 19:05:02 +08:00 • committed by GitHub
commit 92e525d2a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -50,6 +50,9 @@
import import
hashes, math hashes, math
when not defined(nimHasEffectsOf):
{.pragma: effectsOf.}
{.pragma: myShallow.} {.pragma: myShallow.}
# For "integer-like A" that are too big for intsets/bit-vectors to be practical, # For "integer-like A" that are too big for intsets/bit-vectors to be practical,
# it would be best to shrink hcode to the same size as the integer. Larger # it would be best to shrink hcode to the same size as the integer. Larger
@ -556,7 +559,7 @@ proc `==`*[A](s, t: HashSet[A]): bool =
s.counter == t.counter and s <= t s.counter == t.counter and s <= t
proc map*[A, B](data: HashSet[A], op: proc (x: A): B {.closure.}): HashSet[B] = proc map*[A, B](data: HashSet[A], op: proc (x: A): B {.closure.}): HashSet[B] {.effectsOf: op.} =
## Returns a new set after applying `op` proc on each of the elements of ## Returns a new set after applying `op` proc on each of the elements of
##`data` set. ##`data` set.
## ##