cstr_core
cstr_core copied to clipboard
How to get the length of a `CStr`?
I would love to see some .len() functions in all the type of this crate.
You can use .to_bytes().len().
Agreeing with @Amanieu. "length" has two distinct meanings here (length with and length without the nul), so it's better to explicitly indicate which length to get either by using .to_bytes() or .to_bytes_with_nul() when asking length.