diff options
Diffstat (limited to 'tests/concepts/titerable.nim')
-rw-r--r-- | tests/concepts/titerable.nim | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/concepts/titerable.nim b/tests/concepts/titerable.nim new file mode 100644 index 000000000..b18658b2a --- /dev/null +++ b/tests/concepts/titerable.nim @@ -0,0 +1,20 @@ +discard """ + nimout: "int\nint" + output: 15 +""" + +import typetraits + +type + Iterable[T] = concept x + for value in x: + type(value) is T + +proc sum*[T](iter: Iterable[T]): T = + static: echo T.name + for element in iter: + static: echo element.type.name + result += element + +echo sum([1, 2, 3, 4, 5]) + |