i did my best to discover why do i get this compile error
and try to fix it but i could not find any help on-line until i decided to bring it here
link to problematic call
this is the code that suppose to compile properly.
extern crate libc;
use libc::c_char;
use libc::c_int;
#[repr(C)]
pub struct PackChar {
pub int_val: c_int,
pub buffer: *mut c_char, // changed
pub buffer_size: c_int, // added
}
#[no_mangle]
pub extern fn get_packs_char(size: c_int) -> *mut PackChar {
use std::char;
let mut out_vec = Vec::new();
for i in 0..size {
let int_0 = '0' as u32;
let last_char_val = int_0 + i as u32 % (126 - int_0);
let last_char = char::from_u32(last_char_val).unwrap();
let buffer = format!("abcdefgHi{}", last_char);
let buffer_size = buffer.len() as c_int;
let buffer = Box::into_raw(buffer.into_bytes().into_boxed_slice()) as *mut _; // added
let pack_char = PackChar {
int_val: i,
buffer: buffer,
buffer_size: buffer_size,
};
out_vec.push(pack_char);
}
Box::into_raw(out_vec.into_boxed_slice()) as *mut _ // changed
}
cargo 0.4.0-nightly (553b363 2015-08-03) (built 2015-08-03)
rustc 1.3.0 (9a92aaf19 2015-09-15)
src\lib.rs:26:22: 26:35 error: use of unstable library feature 'box_raw': may be r
src\lib.rs:26 let buffer = Box::into_raw(buffer.into_bytes().into_boxed_sl
^~~~~~~~~~~~~
note: in expansion of for loop expansion
src\lib.rs:19:5: 35:6 note: expansion site
src\lib.rs:37:5: 37:18 error: use of unstable library feature 'box_raw': may be re
src\lib.rs:37 Box::into_raw(out_vec.into_boxed_slice()) as *mut _ // changed
^~~~~~~~~~~~~