Add convenience constructor for null-terminated byte literals#233
Add convenience constructor for null-terminated byte literals#233kaidokert wants to merge 1 commit intobluss:masterfrom
Conversation
|
@bluss anyway we could look to get this merged? |
|
Hm it kind of needs a better name or description, doesn't it? Nothing from the current name makes it clear what it does (that it will truncate at the null terminator). |
You can create this function in your own crate, too, by creating an extension trait. You don't have to wait for this (or similar PRs). |
Yep have done so for now, little wrapper struct does this on our side. Would be a nice one to get merged. |
Fair point, null terminated could be a bit of a misnomer here as it will break at the first null and truncates. Either way this doesn't have to be urgently looked at as we easily implemented this. |
This adds a small convenience function for making ArrayStrings out of null-terminated C-style byte buffers, by truncating the result to first null-terminator, if present.
Of course this a pretty trivial utility to keep as a free-standing function in code that needs to deal with C input, so maybe not a great fit here.