20 stable releases

Uses old Rust 2015

1.3.3 May 1, 2019
1.3.2 Aug 2, 2018
1.3.1 Jun 16, 2018
1.3.0 Jul 21, 2017
1.0.10 Mar 25, 2015

#12 in #c

Download history 812/week @ 2020-04-14 800/week @ 2020-04-21 806/week @ 2020-04-28 772/week @ 2020-05-05 695/week @ 2020-05-12 505/week @ 2020-05-19 574/week @ 2020-05-26 689/week @ 2020-06-02 689/week @ 2020-06-09 580/week @ 2020-06-16 558/week @ 2020-06-23 529/week @ 2020-06-30 540/week @ 2020-07-07 560/week @ 2020-07-14 904/week @ 2020-07-21 713/week @ 2020-07-28

3,328 downloads per month
Used in 68 crates (7 directly)

Apache-2.0/MIT

16KB
337 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};

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

    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