Macro cluCStr::cstr

source ·
cstr!() { /* proc-macro */ }
Expand description

Safe and efficient creation of “CStr” with zero-byte checking and support for concatenating multiple values.

use cluCStr::cstr;
use core::ffi::CStr;
 
assert_eq!(cstr!("test").to_bytes(), b"test");
assert_eq!(cstr!(b"test", 1).to_bytes(), b"test1");
assert_eq!(cstr!("test1", "test", 2).to_bytes(), b"test1test2");
assert_eq!(cstr!(1u8).to_bytes(), &[1u8] as &[u8]);
assert_eq!(cstr!(1u8, 2u8, 3u8,).to_bytes(), &[1u8, 2, 3] as &[u8]);
assert_eq!(cstr!(1).to_bytes(), b"1");
assert_eq!(cstr!(1, 2, 3, 4, 5,).to_bytes(), b"12345");