Dotted notation, also called the dot operator, uses a period to select a tuple item or access a type's member or method. Tuple items use numbers after the dot, such as random_tuple.0. section 3.1.3 section 4.3
Use the dot operator in several closely related ways:
- Select tuple elements with positions beginning at 0: random_tuple.0, random_tuple.1, and so on. section 3.1.3
- Call methods with value.method(), as in my_name.is_empty(). Rust automatically dereferences references as needed to find the original type. section 4.3
- Access struct fields through a reference with expressions such as person.name and person.happiness. section 4.2
Calling a method through references
A String reference normally requires dereferencing before reaching the value. However, a double reference can call the method directly: let double_ref = &&my_name; println!("{}", double_ref.is_empty());. The dot operator performs as much dereferencing as the method call needs, avoiding repeated * and & syntax. section 4.3
fn main() {
let my_name = "Billy".to_string();
let double_ref = &&my_name;
println!("{}", double_ref.is_empty());
}
Compare a double reference with a direct method call, then contrast it with the explicit dereferencing form. section 4.3








