fn main() { let x = (1, 2, (), "hello"); let y = x; println!("{:?}, {:?}", x, y); }
The above code is the solution of 5th code snippet of topic named ownership.
The correct solution is here:
fn main() { let x = (1, 2, (), "hello"); let y = &x; println!("{:?}, {:?}", x, y); }
As "y=x" will take the ownership of "x" and we are using the "x" in "println!" and code panics.