Macro cstr::cstr [] [src]

macro_rules! cstr {
    ($t: tt) => { ... };
}

Expands to a expression typed &'static CStr with the given characters. (It currently only supports a UTF-8 string as input.)

Note that the expanded expression cannot be used to initialize const currently.

Example

#[macro_use] extern crate cstr;
use std::ffi::CStr;

let test = cstr!("hello");
assert_eq!(test, CStr::from_bytes_with_nul(b"hello\0").unwrap());