#string #cstring #cstr #ffi #ffistrings

stringer

An easy way to turn an Unsafe *const c_char into a Rust String type and return a pointer

6 releases

Uses old Rust 2015

0.1.6 Jun 10, 2016
0.1.5 Jun 10, 2016
0.1.2 May 29, 2016

#2285 in Rust patterns

MIT license

1KB

Stringer

An easy way to turn an unsafe *const c_char into a Rust String type and return a pointer for FFI.

Functions

turn_into_pointer

turn_into_pointer(string: String)  -> CString

Takes a Rust String type and returns a CString.

make_string

make_string(unsafe_string: *const c_char) -> String

Takes a *const c_char and returns a Rust String type.

Example on how to load this into your project:

Cargo.toml

[dependencies]
stringer = "0.1.6"

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

No runtime deps