How to convert c_vec to [u8]?


I’m working with the lodepng library, and am getting a ‘c_vec’ returned from the encode_memory function.

I’m sure I’m doing something stupid but I’m starting to go in circles, how can I go from c_vec to the [u8], that I need to pass into the “put_s3” function? Surely there is something more efficient than copying one byte at a time? It seems like into_inner() or as_ref() or as_mut() functions in the c_vec library should do it and can copy it by copying a whole chunk of memory at a time?

Thanks in advance!

Using the crates:

Here is the c_vec crate:


It looks like you can use c_vec.as_ref() to get a slice; you should be able to pass that directly to put_s3. Does that not work for some reason?


Nvm… I was being stupid and trying to do more than just call ‘as_ref’, for some reason thought I had to cast it into u8 as well. That seems to have done it. Compiling anyway. Thank you!