macro_rules! const_null_terminated_str {
($strval:expr) => { ... };
}Expand description
Create a null-terminated utf-8 str as an rvalue. Appends a NUL byte to the passed string.
use null_terminated_str::{
const_null_terminated_str,
NullTerminatedStr
};
use std::ops::Deref;
const S: &NullTerminatedStr = const_null_terminated_str!("Hello, World!");
assert_eq!(S.deref(), "Hello, World!");If the str contains NULL bytes, then the compilation
would fail.
ⓘ
use null_terminated_str::{
const_null_terminated_str,
NullTerminatedStr
};
use std::ops::Deref;
const S: &NullTerminatedStr = const_null_terminated_str!("Hello,\0 World!");
assert_eq!(S.deref(), "Hello, World!");