Tuples

Contents

Tuples#

Anonymous fixed-size, mixed-type records.

let pair: (i32, &str) = (1, "one");

Destructure with a pattern.

let (n, s) = pair;

Index by position.

println!("{} {}", pair.0, pair.1);

The empty tuple () is the unit type; the operator uses it where a return value is needed but none is meaningful.

References#