authorgravatar for datamanrb@gmail.comdata-man <datamanrb@gmail.com> 2020-05-24 22:31:51+05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-05-24 20:48:29-04:00
logdb0c30446a8522538ab6088f9a28da951143e5e5
tree7ba3e8ed8b85d126f59576829db628870ca386cf
parentb13dd3cf61fc01b189b5b585651f46de9319953e

Supports vectors in mem.zeroes


1 files changed, 9 insertions(+), 1 deletions(-)

lib/std/mem.zig+9-1
......@@ -402,7 +402,9 @@ pub fn zeroes(comptime T: type) T {
402402 }
403403 return [_]info.child{zeroes(info.child)} ** info.len;
404404 },
405 .Vector,
405 .Vector => |info| {
406 return @splat(info.len, zeroes(info.child));
407 },
406408 .ErrorUnion,
407409 .ErrorSet,
408410 .Union,
......@@ -458,6 +460,9 @@ test "mem.zeroes" {
458460 },
459461
460462 array: [2]u32,
463 vector_u32: meta.Vector(2, u32),
464 vector_f32: meta.Vector(2, f32),
465 vector_bool: meta.Vector(2, bool),
461466 optional_int: ?u8,
462467 empty: void,
463468 sentinel: [3:0]u8,
......@@ -484,6 +489,9 @@ test "mem.zeroes" {
484489 for (b.array) |e| {
485490 testing.expectEqual(@as(u32, 0), e);
486491 }
492 testing.expectEqual(@splat(2, @as(u32, 0)), b.vector_u32);
493 testing.expectEqual(@splat(2, @as(f32, 0.0)), b.vector_f32);
494 testing.expectEqual(@splat(2, @as(bool, false)), b.vector_bool);
487495 testing.expectEqual(@as(?u8, null), b.optional_int);
488496 for (b.sentinel) |e| {
489497 testing.expectEqual(@as(u8, 0), e);