style
This commit is contained in:
24
src/nu.zig
24
src/nu.zig
@@ -32,6 +32,18 @@ pub fn run() !void {
|
||||
try invoke_hook("nu_close", .{});
|
||||
}
|
||||
|
||||
// todo specify hook type.
|
||||
// - special handling for error unions
|
||||
// - allow per-hook state somehow declared in the handler
|
||||
|
||||
pub fn invoke_hook(comptime name: []const u8, args: anytype) !void {
|
||||
inline for (modules) |module| {
|
||||
if (@hasDecl(module, name)) {
|
||||
try invoke(@field(module, name), args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn invoke(func: anytype, args: anytype) !void {
|
||||
if (@typeInfo(@TypeOf(func)).Fn.return_type) |R| {
|
||||
switch (@typeInfo(R)) {
|
||||
@@ -44,15 +56,3 @@ fn invoke(func: anytype, args: anytype) !void {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// todo specify hook type.
|
||||
// - special handling for error unions
|
||||
// - allow per-hook state somehow declared in the handler
|
||||
|
||||
pub fn invoke_hook(comptime name: []const u8, args: anytype) !void {
|
||||
inline for (modules) |module| {
|
||||
if (@hasDecl(module, name)) {
|
||||
try invoke(@field(module, name), args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user