diff options
| author | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-31 15:31:41 +0000 |
|---|---|---|
| committer | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-31 15:31:41 +0000 |
| commit | ccc53b11a0e273f46cb40e5f0eb32a74ab6750bf (patch) | |
| tree | 8a4422c1d74dc4dcd951daf4555511b26b0a2e3b /std | |
| parent | 051400c70a4d5384923113cfbcbc69e8e58d27a0 (diff) | |
Fix for #159
Diffstat (limited to 'std')
| -rw-r--r-- | std/mem.zc | 23 | ||||
| -rw-r--r-- | std/slice.zc | 5 |
2 files changed, 6 insertions, 22 deletions
@@ -49,28 +49,7 @@ impl Box<T> { } } -struct Slice<T> { - data: T*; - len: usize; -} - -impl Slice<T> { - fn new(data: T*, len: usize) -> Self { - return Self { data: data, len: len }; - } - - fn get(self, i: usize) -> T { - return self.data[i]; - } - - fn set(self, i: usize, val: T) { - self.data[i] = val; - } - - fn is_empty(self) -> bool { - return self.len == 0; - } -} +// Note: Slice<T> is defined in std/slice.zc with iteration support fn mem_zero<T>(ptr: T*, count: usize) { memset(ptr, 0, sizeof(T) * count); diff --git a/std/slice.zc b/std/slice.zc index 7ace396..3c317ca 100644 --- a/std/slice.zc +++ b/std/slice.zc @@ -32,6 +32,11 @@ impl Slice<T> { return Slice<T> { data: arr, len: len }; } + // Alias for backwards compatibility with std/mem.zc + fn new(data: T*, len: usize) -> Slice<T> { + return Slice<T> { data: data, len: len }; + } + fn iterator(self) -> SliceIter<T> { return SliceIter<T> { data: self.data, |
