19 stable releases

1.3.2 Aug 2, 2018
1.3.1 Jun 16, 2018
1.3.0 Jul 21, 2017
1.2.0 Dec 30, 2016
1.0.10 Mar 25, 2015

#7 in FFI

Download history 1234/week @ 2018-05-11 1319/week @ 2018-05-18 1263/week @ 2018-05-25 1271/week @ 2018-06-01 1317/week @ 2018-06-08 1277/week @ 2018-06-15 1367/week @ 2018-06-22 1663/week @ 2018-06-29 1695/week @ 2018-07-06 1371/week @ 2018-07-13 1195/week @ 2018-07-20 1147/week @ 2018-07-27 1237/week @ 2018-08-03

5,785 downloads per month
Used in 71 crates (5 directly)

Apache-2.0/MIT

16KB
332 lines

c_vec Build Status

Structures to wrap C arrays. Here's a little example:

extern crate libc;
extern crate c_vec;

use c_vec::{CVec, CSlice};
use std::ptr::Unique;

fn some_func(cvec: *mut libc::c_int, len: uint) {
    // safe wrapper, you can pass a destructor with new_with_dtor() method
    let v = CVec::new(Unique::new(cvec), len);
    // unsafe wrapper with no destructor
    let s = CSlice::new(cvec, len);

    println!("cvec:   converted from c array: {}", v.as_ref());
    println!("cslice: converted from c array: {}", s.as_mut());
}

Usage

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

[dependencies]
c_vec = "^1.0.0"

Here's the crates.io page for c_vec.

License

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

No runtime deps