While rust's stdlib has some good basic options for C-string support, it has some glaring issues when dealing with C functions that accept or return arrays of structures containing C-string pointers or arrays. This crate aims to help fill that niche with safe, fast, ergonomic alternatives.
|C type||ABI compatible Rust||null|
|❌ undefined behavior ❌|
- Pro: Can't get any simpler for basic interop!
- Con: Requires
unsafeto so much as shake a stick at.
- Con: Easy to create undefined behavior by messing up edge cases involving null.
- Con: Easy to create undefined behavior by creating dangling poniters and other lifetime issues (raw pointers have no lifetimes.)
- Con: Fairly unergonomic to use directly.
- Pro: Relatively safe!
- Con: Immediate
O(n)length check on construction, even if you never use the string.
- Con: Being a DST (at least at the time of writing / rust 1.48.0), this isn't ABI compatible with
*const c_charand thus cannot be embedded in zero-conversion structures.
- Pro: Dynamically allocated!
- Con: Dynamically allocated.
The buffer in question is too small to contain the string in question
The string in question contains no terminal