blob: 4c7e54ad91e1719bb8e5d3870b06a44141b43970 [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);
// -- Traits --
println!("p = {}", p.to_string());
}