Skip to content

Methods

Method declaration syntax:

type Counter struct {
value: i32 = 0
}
fn Counter::Read(&self) -> i32 {
return self.value
}
fn Counter::Inc(&mut self) {
self.value += 1
}

Static method form (no receiver):

fn Counter::New() -> Counter {
return .{}
}