t15428.nim 372 B

12345678910111213141516171819202122
  1. discard """
  2. cmd: "nim $target --mm:refc $file"
  3. output: '''5
  4. 5
  5. [1, 2, 3, 4, 5]
  6. (data: [1, 2, 3, 4, 5])
  7. '''
  8. """
  9. proc take[T](f: openArray[T]) =
  10. echo f.len
  11. let f = @[0,1,2,3,4]
  12. take(f.toOpenArray(0,4))
  13. {.experimental: "views".}
  14. type
  15. Foo = object
  16. data: openArray[int]
  17. let f2 = Foo(data: [1,2,3,4,5])
  18. echo f2.data.len
  19. echo f2.data
  20. echo f2