Skip to content

Commit c6cbb51

Browse files
committed
Fix deprecations
1 parent 43bcbca commit c6cbb51

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/private/util.nim

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# Licensed under terms of MIT license (see LICENSE)
33

44

5-
import strutils, macros
5+
import strutils, unicode, macros
66

77

8-
template any_it*(lst, pred: expr): expr =
8+
template any_it*(lst: typed, pred: untyped): bool =
99
## Does `pred` return true for any of the `it`s of `lst`?
1010
var result {.gensym.} = false
1111
for it {.inject.} in lst:
@@ -14,7 +14,7 @@ template any_it*(lst, pred: expr): expr =
1414
break
1515
result
1616

17-
template map_it*(lst, typ, op: expr): expr =
17+
template map_it*(lst, typ: typed, op: untyped): untyped =
1818
## Returns `seq[typ]` that contains `op` applied to each `it` of `lst`
1919
var result {.gensym.}: seq[typ] = @[]
2020
for it {.inject.} in items(lst):
@@ -43,11 +43,16 @@ proc partition*(s, sep: string): tuple[left, sep, right: string] =
4343
4444
proc is_upper*(s: string): bool =
4545
## Is the string in uppercase (and there is at least one cased character)?
46-
let upper = s.to_upper()
47-
s == upper and upper != s.to_lower()
46+
# Backwards compatibility
47+
when compiles(unicode.to_upper("")):
48+
let upper = unicode.to_upper(s)
49+
s == upper and upper != unicode.to_lower(s)
50+
else:
51+
let upper = strutils.to_upper(s)
52+
s == upper and upper != strutils.to_lower(s)
4853
4954
50-
macro gen_class*(body: stmt): stmt {.immediate.} =
55+
macro gen_class*(body: untyped): untyped =
5156
## When applied to a type block, this will generate methods
5257
## that return each type's name as a string.
5358
for typ in body[0].children:

0 commit comments

Comments
 (0)