expression
Rust Method calls and receivers
A method is invoked on a receiver, the value before the dot. Rust can automatically borrow or dereference the receiver as needed by method lookup. Here `len` reads a string without taking ownership. Expected output (not executed): lamp: 4 Why: The string still belongs to label; len reads its byte count. Common mistake: Do not assume every method consumes its receiver, or that every method preserves it: inspect its signature.
Formal Syntax & Structure
rust syntaxrust
receiver.method(arguments)Working Example
Example Snippetrust
fn main() { let label = String::from("lamp"); let length = label.len(); println!("{label}: {length}");}