This might come handy when you need to work with arrays, not slices:
fn myFunc(array: anytype) void {
const real_array: [array.len]u32 = array;
return myFuncSlice(&real_array);
}
fn myFuncSlice(slice: []const u32) void {
...
}
test "from array" {
var arr: [3]u32 = .{ 1, 2, 3};
myFunc(arr);
}
test "from anonymous literal" {
myFunc(.{ 1,2,3,4 });
}
Latest comments (0)