Dot and colon syntax

https://doc.rust-lang.org/reference/expressions/field-expr.html https://doc.rust-lang.org/reference/expressions/path-expr.html

Dots are used to access fields of a structure or a tuple:

#![allow(unused)]
fn main() {
let a = (5, 4, 3, 2, 1, 0);
println!("{}", a.2); // will print 3

let my_struct = give_me_my_struct_please();
my_struct.my_field; // this is "fasterthanlime"
}

The dot syntax is also used for method calls:

"Hello, Braiins!".len(); // 15

The dot syntax implicitly borrows self where applicable so that you don't have to do things like (&self).my_method() if a method requires an "&Self"-type parameter.

The double-colon, ::, is similar but for accessing members of namespaces (often refereed to as crate/module paths).

#![allow(unused)]
fn main() {
std::process::exit(1); // exit with an error
}

In use imports, curly brackets are used to denote multiple imports.

The following three examples are the same:

#![allow(unused)]
fn main() {
use std::io::Read;
use std::io::Write;
}
#![allow(unused)]
fn main() {
use std::io::{Read, Write};
}
#![allow(unused)]
fn main() {
use std::{io::Read, io::Write};
}

You can also use glob imports or aliases

#![allow(unused)]
fn main() {
use std::io::*; // not recommended
use std::process::exit as quit;

quit(0);
}

You can also use the double-colon for static methods (alternatively called associated functions) of a type:

#![allow(unused)]
fn main() {
let v = Vec::new(); // The goto collection/list type
}