Error when build via cargo


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;

pub struct PackChar {
    pub int_val: c_int,
    pub buffer: *mut c_char, // changed
    pub buffer_size: c_int, // added

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,


    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\ 26:35 error: use of unstable library feature 'box_raw': may be r
src\         let buffer = Box::into_raw(buffer.into_bytes().into_boxed_sl
note: in expansion of for loop expansion
src\ 35:6 note: expansion site
src\ 37:18 error: use of unstable library feature 'box_raw': may be re
src\     Box::into_raw(out_vec.into_boxed_slice()) as *mut _ // changed


Use a nightly instead of stable? Cargo is not an issue here.


If you update to Rust 1.4, it should work. Just tried on the playpen. In 1.3, that feature was still unstable, hence why it won’t work.


@DanielKeep cheers i was sure i have most updated version thanks !


do i need this at the top ?



No. It works just fine in stable on playpen.


thanks a lot for your help @DanielKeep ! you too @PeteVine