2
2
# Licensed under terms of MIT license (see LICENSE)
3
3
4
4
5
- import strutils, macros
5
+ import strutils, unicode, macros
6
6
7
7
8
- template any_it* (lst, pred: expr ): expr =
8
+ template any_it* (lst: typed , pred: untyped ): bool =
9
9
# # Does `pred` return true for any of the `it`s of `lst`?
10
10
var result {.gensym.} = false
11
11
for it {.inject.} in lst:
@@ -14,7 +14,7 @@ template any_it*(lst, pred: expr): expr =
14
14
break
15
15
result
16
16
17
- template map_it* (lst, typ, op: expr ): expr =
17
+ template map_it* (lst, typ: typed , op: untyped ): untyped =
18
18
# # Returns `seq[typ]` that contains `op` applied to each `it` of `lst`
19
19
var result {.gensym.}: seq [typ] = @ []
20
20
for it {.inject.} in items(lst):
@@ -43,11 +43,16 @@ proc partition*(s, sep: string): tuple[left, sep, right: string] =
43
43
44
44
proc is_upper*(s: string ): bool =
45
45
## 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)
48
53
49
54
50
- macro gen_class*(body: stmt ): stmt {.immediate.} =
55
+ macro gen_class*(body: untyped ): untyped =
51
56
## When applied to a type block, this will generate methods
52
57
## that return each type 's name as a string .
53
58
for typ in body[ 0].children:
0 commit comments