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:
parent
e6616115e6
commit
57b7841c18
6 changed files with 100 additions and 44 deletions
|
|
@ -1,27 +0,0 @@
|
|||
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])
|
||||
Loading…
Add table
Add a link
Reference in a new issue