Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::boxed::Box;
- use libc::c_void;
- fn main() {
- show_ptr(get_ptr());
- }
- fn get_ptr() -> (usize, *mut c_void) {
- let x = vec!["Hello".to_string(), "World".to_string()].into_boxed_slice();
- (x.len(), Box::into_raw(x) as *mut c_void)
- }
- fn show_ptr(ptr: (usize, *mut c_void)) {
- let x = unsafe { Vec::from_raw_parts(ptr.1 as *mut String, ptr.0, ptr.0).into_boxed_slice() };
- println!("{:?}", x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement