| ... | ... | @@ -382,6 +382,9 @@ pub fn zeroes(comptime T: type) T { |
| 382 | 382 | } |
| 383 | 383 | }, |
| 384 | 384 | .Array => |info| { |
| 385 | if (info.sentinel) |sentinel| { |
| 386 | return [_:sentinel]info.child{zeroes(info.child)} ** info.len; |
| 387 | } |
| 385 | 388 | return [_]info.child{zeroes(info.child)} ** info.len; |
| 386 | 389 | }, |
| 387 | 390 | .Vector, |
| ... | ... | @@ -442,6 +445,7 @@ test "mem.zeroes" { |
| 442 | 445 | array: [2]u32, |
| 443 | 446 | optional_int: ?u8, |
| 444 | 447 | empty: void, |
| 448 | sentinel: [3:0]u8, |
| 445 | 449 | }; |
| 446 | 450 | |
| 447 | 451 | const b = zeroes(ZigStruct); |
| ... | ... | @@ -466,6 +470,9 @@ test "mem.zeroes" { |
| 466 | 470 | testing.expectEqual(@as(u32, 0), e); |
| 467 | 471 | } |
| 468 | 472 | testing.expectEqual(@as(?u8, null), b.optional_int); |
| 473 | for (b.sentinel) |e| { |
| 474 | testing.expectEqual(@as(u8, 0), e); |
| 475 | } |
| 469 | 476 | } |
| 470 | 477 | |
| 471 | 478 | pub fn secureZero(comptime T: type, s: []T) void { |