| ... | ... | @@ -341,8 +341,8 @@ pub fn zeroes(comptime T: type) T { |
| 341 | 341 | } |
| 342 | 342 | }, |
| 343 | 343 | .Array => |info| { |
| 344 | | if (info.sentinel) |sentinel| { |
| 345 | | return [_:info.sentinel]info.child{zeroes(info.child)} ** info.len; |
| 344 | if (info.sentinel) |sentinel| { |
| 345 | return [_:sentinel]info.child{zeroes(info.child)} ** info.len; |
| 346 | 346 | } |
| 347 | 347 | return [_]info.child{zeroes(info.child)} ** info.len; |
| 348 | 348 | }, |
| ... | ... | @@ -407,6 +407,7 @@ test "mem.zeroes" { |
| 407 | 407 | array: [2]u32, |
| 408 | 408 | optional_int: ?u8, |
| 409 | 409 | empty: void, |
| 410 | sentinel: [3:0]u8, |
| 410 | 411 | }; |
| 411 | 412 | |
| 412 | 413 | const b = zeroes(ZigStruct); |
| ... | ... | @@ -431,6 +432,9 @@ test "mem.zeroes" { |
| 431 | 432 | testing.expectEqual(@as(u32, 0), e); |
| 432 | 433 | } |
| 433 | 434 | testing.expectEqual(@as(?u8, null), b.optional_int); |
| 435 | for (b.sentinel) |e| { |
| 436 | testing.expectEqual(@as(u8, 0), e); |
| 437 | } |
| 434 | 438 | } |
| 435 | 439 | |
| 436 | 440 | pub fn secureZero(comptime T: type, s: []T) void { |
| ... | ... | @@ -504,7 +508,7 @@ pub const toSlice = @compileError("deprecated; use std.mem.spanZ"); |
| 504 | 508 | /// the constness of the input type. `[*c]` pointers are assumed to be 0-terminated, |
| 505 | 509 | /// and assumed to not allow null. |
| 506 | 510 | pub fn Span(comptime T: type) type { |
| 507 | | switch(@typeInfo(T)) { |
| 511 | switch (@typeInfo(T)) { |
| 508 | 512 | .Optional => |optional_info| { |
| 509 | 513 | return ?Span(optional_info.child); |
| 510 | 514 | }, |