make more things compile without isNil
This commit is contained in:
parent
7896903fd0
commit
dbd21d670c
3 changed files with 3 additions and 4 deletions
|
|
@ -654,7 +654,7 @@ proc isValid*[A](s: OrderedSet[A]): bool =
|
||||||
## proc saveTarotCards(cards: OrderedSet[int]) =
|
## proc saveTarotCards(cards: OrderedSet[int]) =
|
||||||
## assert cards.isValid, "Pass an initialized set!"
|
## assert cards.isValid, "Pass an initialized set!"
|
||||||
## # Do stuff here, may crash in release builds!
|
## # Do stuff here, may crash in release builds!
|
||||||
result = not s.data.isNil
|
result = s.data.len > 0
|
||||||
|
|
||||||
proc len*[A](s: OrderedSet[A]): int {.inline.} =
|
proc len*[A](s: OrderedSet[A]): int {.inline.} =
|
||||||
## Returns the number of keys in `s`.
|
## Returns the number of keys in `s`.
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,7 @@ proc caseTree(lvl: int = 0): PCaseNode =
|
||||||
proc finalizeNode(n: PNode) =
|
proc finalizeNode(n: PNode) =
|
||||||
assert(n != nil)
|
assert(n != nil)
|
||||||
write(stdout, "finalizing: ")
|
write(stdout, "finalizing: ")
|
||||||
if isNil(n.data): writeLine(stdout, "nil!")
|
writeLine(stdout, "not nil")
|
||||||
else: writeLine(stdout, "not nil")
|
|
||||||
|
|
||||||
var
|
var
|
||||||
id: int = 1
|
id: int = 1
|
||||||
|
|
|
||||||
|
|
@ -315,7 +315,7 @@ checkOptions({optFilenames, optReplace}, "filenames", "replace")
|
||||||
|
|
||||||
if optStdin in options:
|
if optStdin in options:
|
||||||
pattern = ask("pattern [ENTER to exit]: ")
|
pattern = ask("pattern [ENTER to exit]: ")
|
||||||
if isNil(pattern) or pattern.len == 0: quit(0)
|
if pattern.len == 0: quit(0)
|
||||||
if optReplace in options:
|
if optReplace in options:
|
||||||
replacement = ask("replacement [supports $1, $# notations]: ")
|
replacement = ask("replacement [supports $1, $# notations]: ")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue