In my situation, the data is saved in a file
first 4 bytes gives the length of array
second 4 bytes gives the type of variable in the array, like 0 means i8, 1 means i16
next the dataset in given type, for example f32
The usage looks like
let mut f = File::open(file_dir).expect("File not found!");
let data = read_data(f);
I tried to find a function to read file like this, but failed.
And I tried to combine match and something like slice::from_raw_parts_mut to get it.
But still, I can do nothing to get a function that can read such file to a vector in different types.
Can anybody show me a function to solve the problem.
Thank you very much.