blob: 1e1eb96f47b9f5d85df15f974536eef7fdc280fa [file] [log] [blame] [view]
# Methods
Methods are annotated similarly to functions:
```rust,editable
struct Owner(i32);
impl Owner {
// Annotate lifetimes as in a standalone function.
fn add_one<'a>(&'a mut self) { self.0 += 1; }
fn print<'a>(&'a self) {
println!("`print`: {}", self.0);
}
}
fn main() {
let mut owner = Owner(18);
owner.add_one();
owner.print();
}
```
### See also:
[methods]
[methods]: ../../fn/methods.md