Crates.io | c_vec |
lib.rs | c_vec |
version | 2.0.0 |
source | src |
created_at | 2015-01-08 22:08:55.828455 |
updated_at | 2020-09-25 16:28:47.143693 |
description | Structures to wrap C arrays |
homepage | |
repository | https://github.com/GuillaumeGomez/c_vec-rs.git |
max_upload_size | |
id | 742 |
size | 45,629 |
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());
}
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
.
This project is under the MIT and Apache 2.0 licenses. Please take a look at the license files for more information.