Add array::zip and Related Macros (#2370)

* zip / zip_into
* Deprecate `add_array` in favour of `push_all` on lists.
* Add support for generic lists for zip.

---------

Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
This commit is contained in:
Zack Puhl
2025-08-16 07:30:24 -04:00
committed by GitHub
parent e35dbd29fb
commit 702b63ddb7
16 changed files with 567 additions and 45 deletions

View File

@@ -317,6 +317,23 @@ macro clone(Allocator allocator, value) @nodiscard
return new(allocator, $typeof(value), value);
}
<*
@param [&inout] allocator : "The allocator used to clone"
@param slice : "The slice to clone"
@return "A pointer to the cloned slice"
@require @typekind(slice) == SLICE || @typekind(slice) == ARRAY
*>
macro clone_slice(Allocator allocator, slice) @nodiscard
{
var $Type = $typeof(slice[0]);
$Type[] new_arr = new_array(allocator, $Type, slice.len);
mem::copy(new_arr.ptr, &slice[0], slice.len * $Type.sizeof);
return new_arr;
}
<*
Clone overaligned values. Must be released using free_aligned.