Hello,
Please help to explain what does let Person { name, ref age } = person;
do exactly in the snippet below? And of cause why we can access name
and age
directly from println!
? Thank you.
fn main() {
#[derive(Debug)]
struct Person { name: String, age: Box<u8>, }
let person = Person { name: String::from("Alice"), age: Box::new(20), };
let Person { name, ref age } = person;
println!("The person's age is {}", age);
println!("The person's name is {}", name);
}