c_str 1.0.3

The old c_str functions
docs.rs failed to build c_str-1.0.3
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: c_str-1.0.8

c_str Build Status

Old rust c_str module. It provides the ToCStr and FromCStr traits. It works just like the old one:

extern crate libc;
extern crate c_str;

use c_str::{FromCStr, ToCStr};

fn some_func(cstr: *const libc::c_char) {
    let s : String = FromCStr::from_c_str(cstr);

    println!("converted from c string: {}", s);
}

fn some_other_func(rstr: &str) {
    unsafe {
        some_c_func(rstr.with_c_str(|s| {
            s
        })
    }
}

Usage

You can use it directly by adding this line to your Cargo.toml file:

[dependencies]
c_str = "^1.0.0"

Here's is the crates.io page for c_str.

License

This project is under the MIT and Apache 2.0 licenses. Please look at the license files for more information.