keyword

Rust self: refer to the receiver or current module

Lowercase `self` names a method receiver, and `self::` starts a path at the current module. In a method, `&self` means the receiver is borrowed. Expected output (not executed): 9 Why: The method reads the first tuple-struct field through the borrowed receiver. Common mistake: `self` and `Self` have distinct meanings; `self` is not the implementing type.

Formal Syntax & Structure

rust syntaxrust
fn method(&self) {}; self::item

Working Example

Example Snippetrust
struct Meter(u32);impl Meter {    fn reading(&self) -> u32 { self.0 }}
fn main() {    let meter = Meter(9);    println!("{}", meter.reading());}
Rust Reference