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

#823 in Data structures

Download history 4207/week @ 2024-03-14 5262/week @ 2024-03-21 5805/week @ 2024-03-28 5658/week @ 2024-04-04 5288/week @ 2024-04-11 6309/week @ 2024-04-18 6118/week @ 2024-04-25 5477/week @ 2024-05-02 9796/week @ 2024-05-09 6543/week @ 2024-05-16 6587/week @ 2024-05-23 5435/week @ 2024-05-30 6027/week @ 2024-06-06 5758/week @ 2024-06-13 7082/week @ 2024-06-20 5137/week @ 2024-06-27

24,858 downloads per month
Used in 91 crates (9 directly)

Apache-2.0/MIT

34KB
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