diff options
| author | Nic Gaffney <gaffney_nic@protonmail.com> | 2025-10-20 02:13:49 -0500 |
|---|---|---|
| committer | Nic Gaffney <gaffney_nic@protonmail.com> | 2025-10-20 02:13:49 -0500 |
| commit | 0729305769365c9d29689a52ec37dbd3818a28a4 (patch) | |
| tree | f710ba5455e6a97a94ad8f8677a6fa011a967616 | |
| parent | 78d191cbf396d2ea32d920282934aa44f8ade4be (diff) | |
| download | funcz-0729305769365c9d29689a52ec37dbd3818a28a4.tar.gz | |
Pointers now must be of size 'many' or 'slice' to be valid
| -rw-r--r-- | src/lib.zig | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lib.zig b/src/lib.zig index 8e99ad3..c84829f 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -40,6 +40,10 @@ pub fn mapAlloc( if(itemsTypeInfo != .array and itemsTypeInfo != .pointer) { @compileError("Expected array or slice, found " ++ @typeName(itemsType)); } + switch (itemsTypeInfo) { + .pointer => |p| if(p.size != .many and p.size != .slice) @compileError("Expected pointer of size 'many' or 'slice', found " ++ @tagName(p)), + else =>{}, + } break :blk []funcTypeInfo.@"fn".return_type.?; } { @@ -68,6 +72,10 @@ pub fn map( @compileError("Expected array, found " ++ @typeName(itemsType)); if(bufferTypeInfo != .array and bufferTypeInfo != .pointer) @compileError("Expected array, found " ++ @typeName(bufferType)); + switch (itemsTypeInfo) { + .pointer => |p| if(p.size != .many and p.size != .slice) @compileError("Expected pointer of size 'many' or 'slice', found '" ++ @tagName(p.size) ++ "'"), + else =>{}, + } for (items, 0..) |item, i| buffer.*[i] = func(item); } |
