Status on stabilizing const_cstr_unchecked

Hi All,

Has there been any discussion about stabilizing const_cstr_unchecked? [link]

I had been interacting with a C library, and there doesn't appear to be a good way to construct a const &Cstr. It would be nice to be able to do:

const VALUE: &std::ffi::CStr = unsafe {
    std::ffi::CStr::from_bytes_with_nul_unchecked(b"Hello World\0")
};

The most recent information I've seen about this suggests a transmute, which doesn't seem to be ideal.

A couple crates exist to handle this sort of scenario:

I recommend you open a new tracking issue and a PR that changes the issue number on the unstable annotation from none to that new issue. Then, that tracking issue would be a good place for discussion.

The current status of all unsafe const fn is that they are blocked on

1 Like