better support for slices as views (#15414)

* moved view tests to tests/views
* refactoring
* more refactorings
* better support for system.toOpenArray for first class view types
This commit is contained in:
Andreas Rumpf 2020-09-27 09:20:10 +02:00 • committed by GitHub
commit 57b7841c18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 100 additions and 44 deletions

27
tests/views/tviews1.nim Normal file
View file

@ -0,0 +1,27 @@
discard """
output: '''11
22
33
3
2
3'''
targets: "c cpp"
"""
{.experimental: "views".}
proc take(a: openArray[int]) =
echo a.len
proc main(s: seq[int]) =
var x: openArray[int] = s
for i in 0 .. high(x):
echo x[i]
take(x)
take(x.toOpenArray(0, 1))
let y = x
take y
main(@[11, 22, 33])