Method Calls: Immutable Borrow

Overview

Methods commonly take &self, which means calling the method immutably borrows the receiver instead of moving it.

This allows read-only behavior on a value while keeping ownership with the caller.

Official Rust Book: Method Syntax


Code example