// 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); | |
} |