Macro byte_strings::const_cstr
source · macro_rules! const_cstr { () => { ... }; ( $($s:expr),* $(,)? ) => { ... }; }
Expand description
const-friendly version of
c_str!.
use ::byte_strings::const_;
use ::core::ffi::CStr;
const MESSAGE: &str = "Hello, World!";
const C_MESSAGE: &CStr = const_::c_str!(MESSAGE);Inner null bytes are still rejected at compile time:
ⓘ
use ::byte_strings::const_;
use ::core::ffi::CStr;
const MESSAGE: &str = "Hell\0, World!";
const C_MESSAGE: &CStr = const_::c_str!(MESSAGE); // Error.