summary refs log tree commit diff stats
path: root/tests/views/tconst_views.nim
blob: d7f1fc481b2d855bd9946835cc0a3da13c99774c (plain) (blame)
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
discard """
  cmd: "nim c --experimental:views $file"
  output: '''(data: [1, 2, 3], other: 4)
[1, 20, 3]'''
"""

type
  Foo = object
    data: openArray[int]
    other: int

const
  c = Foo(data: [1, 2, 3], other: 4)

  c2 = Foo(data: [1, 20, 3], other: 4)

proc `$`(x: openArray[int]): string =
  result = "["
  for i in x:
    if result.len > 1: result.add ", "
    result.add $i
  result.add "]"

echo c
echo c2.data