I am new to rust and am following along with the official guide and have a question about the following section in chapter 5.2:
#[derive(Debug)] struct Rectangle {
width: u32,
height: u32, }
fn main() {
let scale = 2;
let rect1 = Rectangle {
width: dbg!(30 * scale),
height: 50,
};
dbg!(&rect1); }
We can put dbg! around the expression 30 * scale and, because dbg! returns ownership of the expression’s value, the width field will get the same value as if we didn’t have the dbg! call there. We don’t want dbg! to take ownership of rect1, so we use a reference to rect1 in the next call.
The guide states that dbg! returns ownership of the width expressions value, then right after it says we dont want dbg! to take ownership of rect1 so we use a reference. Why wouldn't dbg! return ownership of rect1?