Crate c_str_macro [−] [src]
A macro to produce C-compatible string data from literals.
In Rust code using FFI bindings, it is often necessary to pass in a static
constant string that must follow the C string format, i.e. be terminated
with a 0 byte. Rust string literals, unlike in C or C++, do not
translate to implicitly null-terminated string data, so the terminating
"\0" has to be explicitly present to make the string safe to pass
to a C API. This is kludgy and can easily be forgotten.
To alleviate this issue, this crate provides the
c_str! macro that
takes a Rust string literal, appends a terminating 0 byte, and casts
the output value to a