I added the last six lines of code to your book example, shown further below. They do not work. Please provide example calls to fn reference, fn mutable reference and fn takes_ownership. Thanks.
fn main() {
struct Circle {
x: f64,
y: f64,
radius: f64,
}
impl Circle {
fn reference(&self) {
println!("taking self by reference!");
}
}
impl Circle {
fn mutable_reference(&mut self) {
println!("taking self by mutable reference!");
}
}
impl Circle {
fn takes_ownership(self) {
println!("taking ownership of self!");
}
}
let a = &Circle { x: 0.0, y: 0.0, radius: 2.0 };
let b = Circle { x: 0.0, y: 0.0, radius: 2.0 };
let c = &mut Circle { x: 0.0, y: 0.0, radius: 2.0 };
println!("{}", a.reference());
println!("{}", b.takes_ownership());
println!("{}", c.mutable_reference());
}