#Standard way to get a [:0]const u8 from a []const u8?

1 messages · Page 1 of 1 (latest)

spiral token
#

I don't mind using an allocator, is there a std function or do i need to manually add the 0 and then cast the pointer?

fair spade
#

well I don't know about a standard way, but you can allocPrintZ with {s}

#

there may be a better way though..

spiral token
#

thats fine for me, thanks 🙂

fair spade
#

bufPrintZ might be better

meager jungle
#

If you know the string has a null sentinel you can use std.mem.span

fair spade
#

since you know how much to allocate

meager jungle
#

Otherwise dupeZ, yes

spiral token
#

dupeZ! nice, that's what I was looking for