Methods
Methods are annotated similarly to functions:
1. struct Owner(i32);
3. impl Owner {
4. // Annotate lifetimes as in a standalone function.
5. fn add_one<'a>(&'a mut self) { self.0 += 1; }
6. fn print<'a>(&'a self) {
7. println!("`print`: {}", self.0);
8. }
9. }
11. fn main() {
12. let mut owner = Owner(18);
14. owner.add_one();
15. owner.print();
16. }
