summary refs log tree commit diff stats
path: root/tests/concepts/titerable.nim
blob: b18658b2a17f9a2e85f823c5bbd0bce30b4796ee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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])