migrate to new mutable decl syntax

This commit is contained in:
2026-08-05 21:53:09 +02:00
parent 1689c4db3c
commit 410246faee
20 changed files with 116 additions and 112 deletions
+3 -3
View File
@@ -17,7 +17,7 @@ init proc($T type, allocator mem.Allocator) ArrayList(T) {
}
deinit proc($T type, list @mut ArrayList(T)) void {
allocation []mut T :: list.items.ptr[..list.capacity]
allocation :: list.items.ptr[..list.capacity]
mem.free(list.allocator, allocation)
list.items = mem.empty(T)
list.capacity = 0
@@ -28,9 +28,9 @@ hide reserve proc($T type, list @mut ArrayList(T), min_capacity usize) void ! me
return
}
new_capacity usize = 8
new_capacity := 8
if list.capacity >= 8 {
half usize :: divtrunc!(list.capacity, 2)
half :: divtrunc!(list.capacity, 2)
if list.capacity > maxval!(usize) - half {
new_capacity = min_capacity
} else {
+3 -3
View File
@@ -2,7 +2,7 @@ import "@std/mem"
import "@std/testing"
handles_append test {
list ArrayList(i32) = init(mem.c_allocator)
list ArrayList(i32) := init(mem.c_allocator)
defer deinit(&list)
try append(&list, 42)
@@ -12,7 +12,7 @@ handles_append test {
}
handles_clear test {
list ArrayList(i32) = init(mem.c_allocator)
list ArrayList(i32) := init(mem.c_allocator)
defer deinit(&list)
try append(&list, 42)
@@ -22,7 +22,7 @@ handles_clear test {
}
handles_reserve test {
list ArrayList(i32) = init(mem.c_allocator)
list ArrayList(i32) := init(mem.c_allocator)
defer deinit(&list)
try reserve(&list, 10)