arrayvec icon indicating copy to clipboard operation
arrayvec copied to clipboard

Add convenience constructor for null-terminated byte literals

Open kaidokert opened this issue 2 years ago • 5 comments

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.

kaidokert avatar Jan 15 '23 18:01 kaidokert

@bluss anyway we could look to get this merged?

Callum-A avatar Jul 19 '24 15:07 Callum-A

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).

bluss avatar Jul 19 '24 16:07 bluss

anyway we could look to get this merged?

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).

tbu- avatar Jul 19 '24 16:07 tbu-

anyway we could look to get this merged?

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.

Callum-A avatar Jul 19 '24 16:07 Callum-A

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).

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.

Callum-A avatar Jul 19 '24 16:07 Callum-A