#Pass struct method as argument to function

1 messages · Page 1 of 1 (latest)

gaunt viper
#

hopefully a quick one: if I have a method on a struct, how can I pass that to another function as an argument? Specifically in relation to httpz, I have a method fn xyz(self: @This(), _: *httpz.Request, res: *httpz.Response) !void that I want to pass to router.get as the handler, but Im getting error: no field named 'xyz' in struct 'main.Server'. I want to pass the method because I hold a handle in @This() to something that I need in the http handler

lucid sundial
#

get it from the type not the instance

#

main.Server.get

gaunt viper
#

I dont think I can do partial function application in zig though, so that wouldn't let me partially apply with self and have httpz complete application with req and resp