Don't expect all keys in hashsets to have $ defined
This commit is contained in:
parent
232d042731
commit
d732279203
1 changed files with 5 additions and 1 deletions
|
|
@ -163,7 +163,11 @@ proc `[]`*[A](s: var HashSet[A], key: A): var A =
|
||||||
var hc: Hash
|
var hc: Hash
|
||||||
var index = rawGet(s, key, hc)
|
var index = rawGet(s, key, hc)
|
||||||
if index >= 0: result = s.data[index].key
|
if index >= 0: result = s.data[index].key
|
||||||
else: raise newException(KeyError, "key not found: " & $key)
|
else:
|
||||||
|
when compiles($key):
|
||||||
|
raise newException(KeyError, "key not found: " & $key)
|
||||||
|
else:
|
||||||
|
raise newException(KeyError, "key not found")
|
||||||
|
|
||||||
proc mget*[A](s: var HashSet[A], key: A): var A {.deprecated.} =
|
proc mget*[A](s: var HashSet[A], key: A): var A {.deprecated.} =
|
||||||
## returns the element that is actually stored in 's' which has the same
|
## returns the element that is actually stored in 's' which has the same
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue