When I see this code everything is clear. We have a reference that we should dereference to manipulate and read data inside of it.
fn twice(x: &mut u8) {
*x = *x * 2;
}
But why does the following code compile?
fn twice(x: &u8) -> u8 {
x * 2
}
Why doesn't Rust demand from me to dereference x
here and requires it in the first example?