diff options
| author | 2021-01-01 21:48:29 +0100 | |
|---|---|---|
| committer | 2021-01-06 01:04:18 +0100 | |
| commit | b9edd067444a0641e7a0ecbb47ef1279b22b8e43 (patch) | |
| tree | 46d06d7f88faf3f39cac55ebfc85a21efda07975 | |
| parent | add readField (diff) | |
| download | zig-sqlite-b9edd067444a0641e7a0ecbb47ef1279b22b8e43.tar.gz zig-sqlite-b9edd067444a0641e7a0ecbb47ef1279b22b8e43.tar.xz zig-sqlite-b9edd067444a0641e7a0ecbb47ef1279b22b8e43.zip | |
implement reading a value into a one-element pointer
| -rw-r--r-- | sqlite.zig | 7 |
1 files changed, 6 insertions, 1 deletions
| @@ -529,7 +529,12 @@ pub fn Iterator(comptime Type: type) type { | |||
| 529 | switch (type_info) { | 529 | switch (type_info) { |
| 530 | .Pointer => |ptr| { | 530 | .Pointer => |ptr| { |
| 531 | switch (ptr.size) { | 531 | switch (ptr.size) { |
| 532 | .One => unreachable, | 532 | .One => { |
| 533 | ret = try allocator.create(ptr.child); | ||
| 534 | errdefer allocator.destroy(ret); | ||
| 535 | |||
| 536 | ret.* = try self.readField(ptr.child, i, .{ .allocator = allocator }); | ||
| 537 | }, | ||
| 533 | .Slice => switch (ptr.child) { | 538 | .Slice => switch (ptr.child) { |
| 534 | u8 => ret = try self.readBytes(PointerType, allocator, i, .Text), | 539 | u8 => ret = try self.readBytes(PointerType, allocator, i, .Text), |
| 535 | else => @compileError("cannot read pointer of type " ++ @typeName(PointerType)), | 540 | else => @compileError("cannot read pointer of type " ++ @typeName(PointerType)), |