1 unstable release

0.1.0 Apr 11, 2024

#1280 in Data structures

Download history 104/week @ 2024-04-11

104 downloads per month

MPL-2.0 license

39KB
585 lines

TODO

Crate is mostly finished, but is going to be fully released alongside another crate when I finish it


lib.rs:

UTF-8 equivalents of std's C string types.

lanyard is an extension of the std::ffi module that adds new Utf8CStr and Utf8CString types. They are like the standard library's CStr and CString types, except they are guaranteed to be valid UTF-8.

Therefore they allow the ability to losslessly convert into strings, they implement Display, etc, etc. The std::ffi types are not guaranteed to be valid UTF-8, which is the right decision for the standard library.

However, in FFI, it's not uncommon to encounter APIs which expect all strings to be UTF-8. This generally requires crate authors to convert between &str and CStr via CString between the Rust-C boundary (which allocates every time).

With UTF-8 C strings, the conversion between a &str and Utf8CStr are made explicit, and allocations can be minimized.

No runtime deps

Features