Closed
Description
The current implementation of CStr::from_bytes_with_nul_unchecked()
is not valid in a const context, but it can easily be tweaked so that it is:
pub const unsafe fn from_bytes_with_nul_unchecked(bytes: &[u8]) -> &Self {
union BytesToCStr<'a> {
bytes: &'a [u8],
cstr: &'a CStr,
}
BytesToCStr { bytes }.cstr
}