Rust data types: scalars, tuples, and arrays
Answer: Every value has a data type in Rust. The chapter looks at scalar types and compound types.
Scalar types
A data type tells Rust what kind of data was specified. The subsets here are scalar and compound.
Rust is statically typed, so it must know variable types at compile time. The compiler can often infer the type from the value.
When several types are possible, you add an annotation, such as let guess: u32 = "42".parse().
A scalar type represents a single value. In Rust the primary scalar types are integers, floating-point numbers, Booleans, and characters.
Built-in integer types include i8, u8, i128, and u128. isize and usize depend on the computer's architecture.
An i8 stores numbers from -128 to 127. A u8 stores numbers from 0 to 255. Signed numbers use two's complement representation.
The floating-point types are f32 and f64, with f64 as the default. All of them are signed and are represented according to IEEE 754.
Rust supports addition, subtraction, multiplication, division, and remainder for number types. Integer division truncates toward zero.
bool has the values true and false, occupies one byte, and is used in if expressions.
char literals use single quotes. The type is 4 bytes and holds a Unicode scalar value.
Compound types
Compound types group several values into one type. The two primitive ones are tuples and arrays.
A tuple can group values of different types. Its length is fixed once declared.
A tuple can be destructured or indexed with a period.
See also
Claims
- id: C1 claim: Rust is statically typed and must know all variable types at compile time. source: S1 evidence: "Rust is a statically typed language, which means that it"
- id: C2 claim: The four primary scalar types are integers, floats, Booleans, and characters. source: S2 evidence: "Rust has four primary scalar types: integers, floating-point numbers, Booleans, and characters."
- id: C3 claim: Tuples and arrays are Rust's two primitive compound types. source: S1 evidence: "Rust has two primitive compound types: tuples and arrays."
Sources
- [S1] Data Types. The Rust Project Developers. https://doc.rust-lang.org/book/ch03-02-data-types.html . License: MIT OR Apache-2.0. Accessed 2026-11-27.
- [S2] Data Types (source). The Rust Project Developers. https://raw.githubusercontent.com/rust-lang/book/main/src/ch03-02-data-types.md . License: MIT OR Apache-2.0. Accessed 2026-11-27.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Rust Project Developers, Data Types; The Rust Project Developers, Data Types (source). MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/book/main/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 Project Developers, Data Types; The Rust Project Developers, Data Types (source). MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT). Copyright the Rust Project Developers.
Cite this
iinventedlight. 2026. "Rust data types: scalars, tuples, and arrays." iinventedlight Library, iil:note:a5tjtd3e, version of 2026-11-27. https://iinventedlight.com/library/notes/rust-data-types/. License: CC-BY-4.0.
@misc{iil_note_a5tjtd3e,
author = {{iinventedlight}},
title = {{Rust data types: scalars, tuples, and arrays}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-27},
url = {https://iinventedlight.com/library/notes/rust-data-types/},
note = {Permanent ID iil:note:a5tjtd3e. 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-data-types.schema.json (schema; CC-BY-4.0)
- rust-data-types.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-data-types.md.