Skip to content

Commit

Permalink
meta: pointerElemType
Browse files Browse the repository at this point in the history
  • Loading branch information
urso committed Jul 29, 2024
1 parent 4653658 commit aec1cf2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/pgzx/meta.zig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ pub inline fn sliceElemType(comptime T: type) type {
};
}

pub inline fn pointerElemType(comptime T: type) type {
return switch (@typeInfo(T)) {
.Pointer => |p| p.child,
else => @compileError("Expected a pointer type"),
};
}

pub inline fn hasSentinal(comptime T: type) bool {
return switch (@typeInfo(T)) {
.Pointer => |p| p.size == .Slice and p.sentinel != null,
Expand Down

0 comments on commit aec1cf2

Please sign in to comment.