From aec1cf26134339fc49f58a2bf7d8b9f5a60eb8c3 Mon Sep 17 00:00:00 2001 From: urso Date: Mon, 29 Jul 2024 16:13:39 +0200 Subject: [PATCH] meta: pointerElemType --- src/pgzx/meta.zig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pgzx/meta.zig b/src/pgzx/meta.zig index 6a6a064..0d2a16c 100644 --- a/src/pgzx/meta.zig +++ b/src/pgzx/meta.zig @@ -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,