breaking change: 'concept' is now a keyword and used instead of 'generic'
This commit is contained in:
parent
210fab10b2
commit
f6ff01572e
15 changed files with 462 additions and 475 deletions
|
|
@ -22,7 +22,7 @@ template reject(e: expr) =
|
|||
static: assert(not compiles(e))
|
||||
|
||||
type
|
||||
Container[T] = generic C
|
||||
Container[T] = concept C
|
||||
C.len is Ordinal
|
||||
items(c) is iterator
|
||||
for value in C:
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ proc isSwizzle(s: string): bool {.compileTime.} =
|
|||
return false
|
||||
|
||||
type
|
||||
StringIsSwizzle = generic value
|
||||
StringIsSwizzle = concept value
|
||||
value.isSwizzle
|
||||
|
||||
SwizzleStr = static[string] and StringIsSwizzle
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ type
|
|||
TObj = object
|
||||
x: int
|
||||
|
||||
Sortable = generic x, y
|
||||
Sortable = concept x, y
|
||||
(x < y) is bool
|
||||
|
||||
ObjectContainer = generic C
|
||||
ObjectContainer = concept C
|
||||
C.len is Ordinal
|
||||
for v in items(C):
|
||||
v.type is tuple|object
|
||||
|
|
@ -38,7 +38,7 @@ proc intval(x: int): int = 10
|
|||
|
||||
# check real and virtual fields
|
||||
type
|
||||
TFoo = generic T
|
||||
TFoo = concept T
|
||||
T.x
|
||||
y(T)
|
||||
intval T.y
|
||||
|
|
@ -50,7 +50,7 @@ proc testFoo(x: TFoo) = discard
|
|||
testFoo(TObj(x: 10))
|
||||
|
||||
type
|
||||
Matrix[Rows, Cols: static[int]; T] = generic M
|
||||
Matrix[Rows, Cols: static[int]; T] = concept M
|
||||
M.M == Rows
|
||||
M.N == Cols
|
||||
M.T is T
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
type
|
||||
hasFieldX = generic z
|
||||
hasFieldX = concept z
|
||||
z.x is int
|
||||
|
||||
obj_x = object
|
||||
|
|
@ -7,7 +7,7 @@ type
|
|||
|
||||
ref_obj_x = ref object
|
||||
x: int
|
||||
|
||||
|
||||
ref_to_obj_x = ref obj_x
|
||||
|
||||
p_o_x = ptr obj_x
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue