| ... | ... | @@ -387,20 +387,21 @@ pub fn indexBufferT(bytes: []const u8, comptime T: type, endian: std.builtin.End |
| 387 | 387 | |
| 388 | 388 | pub fn BufIndexer(comptime T: type, comptime endian: std.builtin.Endian) type { |
| 389 | 389 | return struct { |
| 390 | | bytes: []const u8, |
| 390 | bytes: [*]const u8, |
| 391 | 391 | max_len: usize, |
| 392 | 392 | |
| 393 | 393 | const Self = @This(); |
| 394 | 394 | |
| 395 | 395 | pub fn init(bytes: []const u8, max_len: usize) Self { |
| 396 | std.debug.assert(bytes.len >= @sizeOf(T) * max_len); |
| 396 | 397 | return .{ |
| 397 | | .bytes = bytes, |
| 398 | .bytes = bytes.ptr, |
| 398 | 399 | .max_len = max_len, |
| 399 | 400 | }; |
| 400 | 401 | } |
| 401 | 402 | |
| 402 | 403 | pub fn at(self: *const Self, idx: usize) T { |
| 403 | | return indexBufferT(self.bytes, T, endian, idx, self.max_len); |
| 404 | return indexBufferT(self.bytes[0 .. @sizeOf(T) * self.max_len], T, endian, idx, self.max_len); |
| 404 | 405 | } |
| 405 | 406 | }; |
| 406 | 407 | } |