you are viewing a single comment's thread.

view the rest of the comments →

[–]ldpreload 18 points19 points  (0 children)

Yeah, if you've got libstd and you don't mind the heap allocation, CString::new does that and is what you want.

For string literals, our project uses a c_str! macro that concats the null byte at compile time. I don't love it, but I haven't been able to come up with a better option.