3 ms·
The generic function is cloning a slice so you need to allocate a new backing array. (think deep-copy) Here that's just a one-liner that works. I need to chec
by aatd86 3y ago
The generic function is cloning a slice so you need to allocate a new backing array. (think deep-copy)
Here that's just a one-liner that works.
I need to check but I think that if you need to keep the same capacity, you may want to preallocate manually.
- mutatio 3y agoI understand that, my point solely rest around defining the clone function from the slices package in the article, explaining why, yet the actual implementation is different. The source code I found via the docs doesn't consider capacity, it merely uses a empty construct and appends.
- aatd86 3y agoAh you're right... It's rather a shallow copy. Good point. I have no clue either. Maybe you can open an issue?