macro_rules! cstr {
($s:expr) => { ... };
}
Expand description
Converts a string slice to &CStr
.
The C-style string is guaranteed to be terminated by a nul byte. This trailing nul byte will be appended by this macro. The provided data should not contain any nul bytes in it.
This macro is const-context only.
See also raw_cstr!
.
Note that Rust has supported C string literals since 1.77.0.
ยงExamples
use core::ffi::CStr;;
const PRINTF_FMT: &CStr = const_str::cstr!("%d\n");