feat: add typed mem.set

This commit is contained in:
2026-10-05 18:54:43 +02:00
parent 9b273f2471
commit d88513e005
4 changed files with 32 additions and 1 deletions
+6
View File
@@ -35,6 +35,12 @@ eql proc($T type, left, right []T) bool {
return true
}
#! assign `value` to each slice element, preserving its typed value rather than repeating a byte.
#! an empty destination is a no-op.
set proc($T type, destination []mut T, value T) void {
for (0..destination.len) |i| destination[i] = value
}
#! allocate memory for a slice of type `T` with `count` elements.
alloc proc($T type, allocator Allocator, count usize) []mut T ! AllocError {
if (count == 0) return empty_slice(T, 0)