#Forwarding an error

1 messages · Page 1 of 1 (latest)

plucky wigeon
#

I have

pub fn loadFoo(path: [] const u8: tmpAlloc: std.mem.Allocator) !foo {
  const path_c: [*:0]const u8 = tmpAlloc.dupeZ(u8, path);
  defer tmpAlloc.free(path_c);
  // do something with path_c that may also return an error.
}
```. 

 ``dupeZ()`` can fail, in which case I would like to simply return that error. I've tried ``const path_c: [*:0]const u8 = try tmpAlloc.dupeZ(u8, path);`` but that doesn't work.
kindred totem
#

dupeZ returns a slice [:0]const u8, not a many pointer [*:0]const u8

plucky wigeon
#

mhh okay

#

yeah that apparently fixes it

#

confusing syntax :/