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 {...@@ -402,7 +402,9 @@ pub fn zeroes(comptime T: type) T {
402 }402 }
403 return [_]info.child{zeroes(info.child)} ** info.len;403 return [_]info.child{zeroes(info.child)} ** info.len;
404 },404 },
405 .Vector,405 .Vector => |info| {
406 return @splat(info.len, zeroes(info.child));
407 },
406 .ErrorUnion,408 .ErrorUnion,
407 .ErrorSet,409 .ErrorSet,
408 .Union,410 .Union,
...@@ -458,6 +460,9 @@ test "mem.zeroes" {...@@ -458,6 +460,9 @@ test "mem.zeroes" {
458 },460 },
459461
460 array: [2]u32,462 array: [2]u32,
463 vector_u32: meta.Vector(2, u32),
464 vector_f32: meta.Vector(2, f32),
465 vector_bool: meta.Vector(2, bool),
461 optional_int: ?u8,466 optional_int: ?u8,
462 empty: void,467 empty: void,
463 sentinel: [3:0]u8,468 sentinel: [3:0]u8,
...@@ -484,6 +489,9 @@ test "mem.zeroes" {...@@ -484,6 +489,9 @@ test "mem.zeroes" {
484 for (b.array) |e| {489 for (b.array) |e| {
485 testing.expectEqual(@as(u32, 0), e);490 testing.expectEqual(@as(u32, 0), e);
486 }491 }
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);
487 testing.expectEqual(@as(?u8, null), b.optional_int);495 testing.expectEqual(@as(?u8, null), b.optional_int);
488 for (b.sentinel) |e| {496 for (b.sentinel) |e| {
489 testing.expectEqual(@as(u8, 0), e);497 testing.expectEqual(@as(u8, 0), e);