Allow for static CStr
This commit is contained in:
+1
-1
@@ -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)]
|
||||
|
||||
+2
-2
@@ -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()
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user