Fixing isNilOrWhitespace to handle empty/nil.
This commit is contained in:
parent
746357404c
commit
f84911364a
1 changed files with 7 additions and 2 deletions
|
|
@ -333,8 +333,13 @@ proc isNilOrEmpty*(s: string): bool {.noSideEffect, procvar, rtl, extern: "nsuIs
|
||||||
|
|
||||||
proc isNilOrWhitespace*(s: string): bool {.noSideEffect, procvar, rtl, extern: "nsuIsNilOrWhitespace".} =
|
proc isNilOrWhitespace*(s: string): bool {.noSideEffect, procvar, rtl, extern: "nsuIsNilOrWhitespace".} =
|
||||||
## Checks if `s` is nil or consists entirely of whitespace characters.
|
## Checks if `s` is nil or consists entirely of whitespace characters.
|
||||||
##
|
if len(s) == 0:
|
||||||
## This is an alias to `isSpace`.
|
return true
|
||||||
|
|
||||||
|
result = true
|
||||||
|
for c in s:
|
||||||
|
if not c.isSpace():
|
||||||
|
return false
|
||||||
|
|
||||||
iterator split*(s: string, seps: set[char] = Whitespace,
|
iterator split*(s: string, seps: set[char] = Whitespace,
|
||||||
maxsplit: int = -1): string =
|
maxsplit: int = -1): string =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue