I am reading raw data from a file and I want to convert it to an integer:
fn main() { let buf: &[u8] = &[0, 0, 0, 1]; let num = slice_to_i8(buf); println!("1 == {}", num); } pub fn slice_to_i8(buf: &[u8]) -> i32 { unimplemented!("what should I do here?") }
I would make a type in C, but what should I do in Rust?
arrays casting slice rust
xrl
source share