Skip to content
Snippets Groups Projects
Verified Commit c41c20a9 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Allow for static CStr

parent dc4aa9cf
No related branches found
No related tags found
No related merge requests found
......@@ -995,7 +995,7 @@ impl CStr {
/// }
/// ```
#[inline]
pub unsafe fn from_bytes_with_nul_unchecked(bytes: &[u8]) -> &CStr {
pub const unsafe fn from_bytes_with_nul_unchecked(bytes: &[u8]) -> &CStr {
&*(bytes as *const [u8] as *const CStr)
}
......
......@@ -5,6 +5,8 @@
#![feature(alloc)]
#![feature(allocator_api)]
#![feature(const_fn)]
#![feature(const_raw_ptr_deref)]
#![feature(const_str_as_bytes)]
#![feature(const_vec_new)]
#![feature(core_intrinsics)]
#![feature(global_asm)]
......
......@@ -3,8 +3,8 @@ macro_rules! c_str {
($lit:expr) => {
#[allow(unused_unsafe)]
unsafe {
$crate::c_str::CStr::from_ptr(
concat!($lit, "\0").as_ptr() as *const $crate::platform::types::c_char
$crate::c_str::CStr::from_bytes_with_nul_unchecked(
concat!($lit, "\0").as_bytes()
)
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment