if you copy from your Array to a seq like that you'll have to call the Array 
destructor, and it's not possible to manually make a seq from an existing 
pointer because seq data has a capacity int laid out before the data.

but lets say instead you had two objects that were compatible: 
    
    
    type
      Brray*[T] = object
        id: string
        cap: int
        data: ptr UncheckedArray[T]
    
    
    Run

then you could, say: 
    
    
    proc move*[T](src: var Array[T]):Brray[T] =
      result.cap = maxElems
      result.data = cast[ptr UncheckedArray[T]](src.data)
    
    proc main() =
      var s = initArray[int]()
      let address = cast[ByteAddress](s.data)
      s.data[10] = 35
      var b = move(s)
      echo b.data[10]       #35
      echo a.data.isNil     #true
      var a: Brray[int] = move(b)
      echo b.data.isNil   #true
      echo a.data[10]      #35
      echo cast[ByteAddress](a.data) == address #true
    
    main()
    
    
    Run

Reply via email to