blob: c8bd848871218e69be7b0d93e1348e83ff97c271 [file] [log] [blame]
// Structs, Borrowing
#![allow(dead_code)]
use rust_tutorial::*;
fn greet_person(p: &Person) {
println!("Hello {} ({})!", p.name, p.age);
}
fn birthday(p: &mut Person) {
p.age += 1;
}
fn main() {
// -- Struct instantiation --
let mut p = Person {
age: 30,
name: "Mary".to_string(),
};
greet_person(&p);
greet_person(&p);
birthday(&mut p);
greet_person(&p);
}