| ... | @@ -23,6 +23,12 @@ pub fn MultiArrayList(comptime T: type) type { | ... | @@ -23,6 +23,12 @@ pub fn MultiArrayList(comptime T: type) type { |
| 23 | len: usize = 0, | 23 | len: usize = 0, |
| 24 | capacity: usize = 0, | 24 | capacity: usize = 0, |
| 25 | | 25 | |
| | 26 | pub const empty: Self = .{ |
| | 27 | .bytes = undefined, |
| | 28 | .len = 0, |
| | 29 | .capacity = 0, |
| | 30 | }; |
| | 31 | |
| 26 | const Elem = switch (@typeInfo(T)) { | 32 | const Elem = switch (@typeInfo(T)) { |
| 27 | .@"struct" => T, | 33 | .@"struct" => T, |
| 28 | .@"union" => |u| struct { | 34 | .@"union" => |u| struct { |
| ... | @@ -474,7 +480,7 @@ pub fn MultiArrayList(comptime T: type) type { | ... | @@ -474,7 +480,7 @@ pub fn MultiArrayList(comptime T: type) type { |
| 474 | pub fn swap(sc: @This(), a_index: usize, b_index: usize) void { | 480 | pub fn swap(sc: @This(), a_index: usize, b_index: usize) void { |
| 475 | inline for (fields, 0..) |field_info, i| { | 481 | inline for (fields, 0..) |field_info, i| { |
| 476 | if (@sizeOf(field_info.type) != 0) { | 482 | if (@sizeOf(field_info.type) != 0) { |
| 477 | const field = @as(Field, @enumFromInt(i)); | 483 | const field: Field = @enumFromInt(i); |
| 478 | const ptr = sc.slice.items(field); | 484 | const ptr = sc.slice.items(field); |
| 479 | mem.swap(field_info.type, &ptr[a_index], &ptr[b_index]); | 485 | mem.swap(field_info.type, &ptr[a_index], &ptr[b_index]); |
| 480 | } | 486 | } |