Skip to content

Instantly share code, notes, and snippets.

@mfpiccolo
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfpiccolo/7487538db56911c914e6 to your computer and use it in GitHub Desktop.
Save mfpiccolo/7487538db56911c914e6 to your computer and use it in GitHub Desktop.
#![feature(libc)]
extern crate libc;
use std::mem;
#[repr(C)]
pub struct RubyArray {
len: libc::size_t,
data: *const libc::c_void,
}
impl RubyArray {
fn from_vec<T>(vec: Vec<T>) -> RubyArray {
let array = RubyArray {
data: vec.as_ptr() as *const libc::c_void,
len: vec.len() as libc::size_t
};
mem::forget(vec);
array
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment