fixes #1444
This commit is contained in:
parent
dcc00b3960
commit
2c99991d16
6 changed files with 165 additions and 9 deletions
|
|
@ -128,7 +128,7 @@ proc mget*[A](s: var TSet[A], key: A): var A =
|
|||
## for sharing.
|
||||
assert s.isValid, "The set needs to be initialized."
|
||||
var index = rawGet(s, key)
|
||||
if index >= 0: result = t.data[index].key
|
||||
if index >= 0: result = s.data[index].key
|
||||
else: raise newException(EInvalidKey, "key not found: " & $key)
|
||||
|
||||
proc contains*[A](s: TSet[A], key: A): bool =
|
||||
|
|
|
|||
|
|
@ -849,13 +849,13 @@ proc contains*[T](s: TSlice[T], value: T): bool {.noSideEffect, inline.} =
|
|||
## assert((1..3).contains(4) == false)
|
||||
result = s.a <= value and value <= s.b
|
||||
|
||||
template `in` * (x, y: expr): expr {.immediate.} = contains(y, x)
|
||||
template `in` * (x, y: expr): expr {.immediate, dirty.} = contains(y, x)
|
||||
## Sugar for contains
|
||||
##
|
||||
## .. code-block:: Nimrod
|
||||
## assert(1 in (1..3) == true)
|
||||
## assert(5 in (1..3) == false)
|
||||
template `notin` * (x, y: expr): expr {.immediate.} = not contains(y, x)
|
||||
template `notin` * (x, y: expr): expr {.immediate, dirty.} = not contains(y, x)
|
||||
## Sugar for not containing
|
||||
##
|
||||
## .. code-block:: Nimrod
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue