21 stable releases

Uses old Rust 2015

2.0.0 Sep 25, 2020
1.3.3 May 1, 2019
1.3.2 Aug 2, 2018
1.3.1 Jun 16, 2018
1.0.10 Mar 25, 2015

#847 in Data structures

Download history 1279/week @ 2022-04-23 1089/week @ 2022-04-30 1694/week @ 2022-05-07 1756/week @ 2022-05-14 1552/week @ 2022-05-21 1842/week @ 2022-05-28 1667/week @ 2022-06-04 1760/week @ 2022-06-11 2084/week @ 2022-06-18 1784/week @ 2022-06-25 1924/week @ 2022-07-02 1813/week @ 2022-07-09 1653/week @ 2022-07-16 1811/week @ 2022-07-23 1977/week @ 2022-07-30 2472/week @ 2022-08-06

8,186 downloads per month
Used in 76 crates (8 directly)

Apache-2.0/MIT

33KB
493 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