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 CStrs means that rustix doesn’t need to copy them into a separate buffer to NUL-terminate them.

Examples

use rustix::cstr;
use rustix::fs::{cwd, statat, AtFlags};

let metadata = statat(cwd(), cstr!("test.txt"), AtFlags::empty())?;