I have a pointer and length. How to get a dynamic array from them?
I have a pointer and length. How to get a dynamic array from them?
Let ptr is a pointer and len is a length, then it is easy as the following:
ptr[0..len]
Note that this does not copy the array, but uses data in-place.
If you want to copy the array, use
ptr[0..len].dup
or
ptr[0..len].idup