Skip to content

Instantly share code, notes, and snippets.

@flaviut
Created July 29, 2014 23:03
Show Gist options
  • Save flaviut/27d152172a4c26b804c3 to your computer and use it in GitHub Desktop.
Save flaviut/27d152172a4c26b804c3 to your computer and use it in GitHub Desktop.
import unsigned
type
FArray* {.unchecked.} [T] = array[0..1, T]
PArray*[T] = ref FArray[T]
proc box*[T](val: T): ref T =
new result
result[] = val
converter array2FArray[I, T](arr: ref array[I, T]): PArray[T] =
cast[PArray[T]](arr)
let x: PArray[int] = PArray(box([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment