7 releases
Uses old Rust 2015
new 0.2.0 | Apr 17, 2025 |
---|---|
0.1.6 | Jun 10, 2016 |
0.1.2 | May 29, 2016 |
#2 in #c-strings
65 downloads per month
5KB
67 lines
Stringer
An easy way to turn an unsafe *const c_char
into a Rust String type and return a pointer for FFI.
Functions
string_to_cstring
string_to_cstring(string: String) -> Result<CString, NulError>
Takes a String
and returns a CString
.
cstr_to_string
cstr_to_string(unsafe_string: *const c_char) -> Result<String, Utf8Error>
Takes a *const c_char
and returns a String
.
Example on how to load this into your project:
Cargo.toml
[dependencies]
stringer = "0.2.0"
In the file you need the functions
extern crate stringer;
use stringer::*;
Things to consider
Due to the nature of what this library is doing:
- This code is unsafe
- Use at your own risk