macro_rules! cstr { ($str:literal) => { ... }; }
Expand description
A macro for CStr
literals.
This can make passing string literals to rustix APIs more efficient, since
most underlying system calls with string arguments expect NUL-terminated
strings, and passing strings to rustix as CStr
s means that rustix doesn’t
need to copy them into a separate buffer to NUL-terminate them.
Examples
use rustix::cstr;
use rustix::fs::{statat, AtFlags, CWD};
let metadata = statat(CWD, cstr!("Cargo.toml"), AtFlags::empty())?;