Skip to content

Commit 329dbba

Browse files
authored
Export meta module. (#23)
I found the helpers in `meta` to be useful in downstream code. For now I'm exporting it under `pgzx.meta`. I wonder if we eventually want to introduce a `pgzx.lib` namespace for common utility functions that are not directly related to Postgres code.
1 parent 51d84a6 commit 329dbba

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/pgzx.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,8 @@ pub const utils = @import("pgzx/utils.zig");
4141
pub const intr = @import("pgzx/interrupts.zig");
4242
pub const testing = @import("pgzx/testing.zig");
4343

44+
// reexport the meta module. Although quite generic, it is useful to have these
45+
// helpers around at times.
46+
pub const meta = @import("pgzx/meta.zig");
47+
4448
pub const guc = utils.guc;

src/pgzx/meta.zig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,10 @@ pub inline fn isPrimitive(comptime T: type) bool {
3232
else => false,
3333
};
3434
}
35+
36+
pub inline fn fnReturnType(comptime T: type, comptime fnName: []const u8) type {
37+
return switch (@typeInfo(@field(T, fnName))) {
38+
.Fn => |f| f.return_type.?,
39+
else => @compileError("Expected a function type"),
40+
};
41+
}

0 commit comments

Comments
 (0)