added toOpenArray builtin for zero-copy slices; syntax sugar yet to come

This commit is contained in:
Araq 2018-03-24 20:26:20 +01:00
commit 1d9343080d
6 changed files with 84 additions and 14 deletions

View file

@ -4131,3 +4131,13 @@ when defined(cpp) and appType != "lib" and not defined(js) and
stderr.write trace & "Error: unhandled exception: " & ex.msg &
" [" & $ex.name & "]\n"
quit 1
when not defined(js):
proc toOpenArray*[T](x: seq[T]; first, last: int): openarray[T] {.
magic: "Slice".}
proc toOpenArray*[T](x: openarray[T]; first, last: int): openarray[T] {.
magic: "Slice".}
proc toOpenArray*[I, T](x: array[I, T]; first, last: I): openarray[T] {.
magic: "Slice".}
proc toOpenArray*(x: string; first, last: int): openarray[char] {.
magic: "Slice".}