Crate raw_cstr

source ·
Expand description

Raw C String conversion and conversion trait

If you want constant C strings, use c"Hello, World" as recently stabilized instead

Traits

  • A type that can be converted to a raw C string

Functions

  • Create a constant raw C string as a *mut i8 from a Rust string reference. C Strings are cached, and creating the same string twice will cost zero additional memory. This is useful when calling C APIs that take a string as an argument, particularly when the string can’t be known at compile time, although this function is also efficient in space (but not time) when a constant string is known. For compile-time constants, you can use c_str!.