Q. What will be the output of the following Rust code?
Code:
fn main() {
let x = 5;
let y = x;
println!("{}", x);
}
β
Correct Answer: (A)
5
Explanation: Since x is a primitive type (Copy trait), y gets a copy and x remains valid. Output is 5.