summary refs log blame commit diff stats
path: root/tests/concepts/t5968.nim
blob: adb374c65a67515ff3ae2359ea8c2f9f7b4ff95b (plain) (tree)



















                                                              
discard """
  exitcode: 0
"""

type
  Enumerable[T] = concept e
    for it in e:
      it is T

proc cmap[T, G](e: Enumerable[T], fn: proc(t: T): G): seq[G] =
  result = @[]
  for it in e: result.add(fn(it))

import json

var x = %["hello", "world"]

var z = x.cmap(proc(it: JsonNode): string = it.getStr & "!")
assert z == @["hello!", "world!"]