3 ms·
var arr: [30_000]u8 = undefined; for (&arr) |*x| x.* = 0;
by kristoff_it 4y ago
var arr: [30_000]u8 = undefined;
for (&arr) |*x| x.* = 0;
- hbossy 4y agoThat sounds like a loop.
- anonymoushn 4y agoyou could initialize it to {0} ** 30000 instead
- AnIdiotOnTheNet 4y agovar arr = std.mem.zeroes([30_000]u8); P.S: Not a loop. The implementation of std.mem.zeroes for an non-sentineled array is: return [_]info.child{zeroes(info.child)} ** info.len; Which in this case will be equivalent to: return [_]u8{0} ** 30_000; Which uses the comptime-only `*` operator to expand the single-item u8 array with value 0 into an array of 30k 0s.