I am learning Rust by writing simple binary decoder.
I'm using a BufferedReader
with the byteorder crate to read numbers, but I'm having problems with reading byte buffers.
I want to read byte data into buffer allocated at runtime. Then I want to pass ownership of this buffer to a struct. When struct is no longer in use, the buffer should be deallocated.
There seems to be no way to allocate array with size determined at runtime on heap except some Vec::with_capacity()
hacks. Any ideas how to implement this with proper Rust semantics?