Rust tuples: fixed-length groups of mixed types
Answer: A tuple groups values with a variety of types into one compound type. Tuples have a fixed length. The tuple without any values has a special name, unit.
What a tuple is
A tuple groups values with a variety of types into one compound type.
The length is fixed: once you declare a tuple, it cannot grow or shrink in size.
Write a comma-separated list of values inside parentheses; each position may have a different type.
Destructuring and indexed access
A variable bound to a tuple holds the whole value, because a tuple is considered a single compound element.
In the book's three-element example, destructuring breaks the single tuple into three parts.
We can also access a tuple element with a period followed by its index.
The empty tuple is called unit. Both the value and the type are written ().
Mixed types and multiple return values
Rust by Example describes a tuple as a collection of values of different types.
Functions can use tuples to return multiple values.
See also
Claims
- id: C1 claim: A tuple groups values of various types into one compound type. source: S1 evidence: "grouping together a number of values with a variety of types"
- id: C2 claim: Tuples have a fixed length once declared. source: S1 evidence: "Tuples have a fixed length"
- id: C3 claim: The first tuple index is 0. source: S1 evidence: "the first index in a tuple is 0"
- id: C4 claim: The empty tuple is called unit and is written (). source: S1 evidence: "The tuple without any values has a special name, unit"
- id: C5 claim: A tuple can hold values of different types. source: S2 evidence: "A tuple is a collection of values of different types"
- id: C6 claim: Functions can return multiple values in a tuple. source: S2 evidence: "Functions can use tuples to return multiple values"
Sources
- [S1] Data Types. The Rust Programming Language. https://doc.rust-lang.org/book/ch03-02-data-types.html . License: MIT OR Apache-2.0. Accessed 2026-11-23.
- [S2] tuples. Rust by Example. https://doc.rust-lang.org/rust-by-example/primitives/tuples.html . License: MIT OR Apache-2.0. Accessed 2026-11-23.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Rust Programming Language, Data Types; Rust by Example, tuples. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT). Copyright the Rust Project Developers. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/rust-by-example/master/LICENSE-MIT). Copyright the Rust Project Developers. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Rust Programming Language, Data Types; Rust by Example, tuples. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT). Copyright the Rust Project Developers. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/rust-by-example/master/LICENSE-MIT). Copyright the Rust Project Developers.
Cite this
iinventedlight. 2026. "Rust tuples: fixed-length groups of mixed types." iinventedlight Library, iil:note:yxknn1n3, version of 2026-11-23. https://iinventedlight.com/library/notes/rust-tuples/. License: CC-BY-4.0.
@misc{iil_note_yxknn1n3,
author = {{iinventedlight}},
title = {{Rust tuples: fixed-length groups of mixed types}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-23},
url = {https://iinventedlight.com/library/notes/rust-tuples/},
note = {Permanent ID iil:note:yxknn1n3. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- rust-tuples.schema.json (schema; CC-BY-4.0)
- rust-tuples.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/rust-tuples.md.