I don't code in C much, but I am currently (attempting) to port a C project to Rust, and I don't understand what this does:
void example(const uint8_t *m, unsigned int r)
{
m += r;
}
After a bit of Googling, I think that it's the same as m = m[r]
. But if that is true, m
and m[r]
are two different data types (right...?). Trying to replicate this in Rust:
fn example(m: &mut [u8], r: u32) {
m = m[r];
}
This gives the error mismatched types: expected `&mut [u8]`, found `u8
, which makes sense. I either did the Rust part wrong, or I did not fully understand what the C part does. Can someone please explain where I went wrong?