summary refs log tree commit diff stats
path: root/lib/system/sysstr.nim
diff options
context:
space:
mode:
authorStephan Diehl <stephan@transvection.de>2015-05-28 15:25:09 +0200
committerStephan Diehl <stephan@transvection.de>2015-05-28 15:25:09 +0200
commit4fcf5adfe2460601bd97b13d3efb3a783ac50623 (patch)
treec58d7238a05cbf9ecae7c7db9b38c6b8daaaba46 /lib/system/sysstr.nim
parent852987c880debe994a5f3950349c0514b3f8ac04 (diff)
downloadNim-4fcf5adfe2460601bd97b13d3efb3a783ac50623.tar.gz
fix for https://github.com/nim-lang/Aporia/issues/69
Diffstat (limited to 'lib/system/sysstr.nim')
0 files changed, 0 insertions, 0 deletions
08:03 +0100 removes 'x is iterator' special casing in the language' href='/ahoang/Nim/commit/tests/concepts/tmanual.nim?h=devel&id=760242b870eb2c9054ef31489abbb230bb56eb72'>760242b87 ^
3bcafb1c3 ^
4d2c94828 ^
ee1b0d8c6 ^













1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42















              
                    

                            
                    


                                 

                          
                 
                   
                      













                                           
discard """
  output: '''1
2
3
4
5
6
a
b
t
e
s
t
'''
"""

template accept(e) =
  static: assert compiles(e)

template reject(e) =
  static: assert(not compiles(e))

type
  Container[T] = concept c
    c.len is Ordinal
    items(c) is T
    for value in c:
      type(value) is T

proc takesIntContainer(c: Container[int]) =
  for e in c: echo e

takesIntContainer(@[1, 2, 3])
reject takesIntContainer(@["x", "y"])

proc takesContainer(c: Container) =
  for e in c: echo e

takesContainer(@[4, 5, 6])
takesContainer(@["a", "b"])
takesContainer "test"
reject takesContainer(10)