[rust-dev] **libc::c_char to ???

Alexander Stavonin a.stavonin at gmail.com
Tue Apr 10 05:16:02 PDT 2012


Hi all, it's again me.

I have a C function returns array of null terminated strings. And I need to convert it to an Rust string type.

C function declaration:

const char** func();

Rust code:

native mod c {
    fn func() -> **libc::c_char;
}

#[test]
fn test_func() {
    let results = c::func();
    // how to print all string in results???
}

I've tried next idea without success:

let v: [str] = methods; // mismatched types: expected `[str]` but found `**core::libc::types::os::arch::c95::c_char` (vector vs *-ptr)


What is the best way to do it?

Regards,
Alexander.


More information about the Rust-dev mailing list