Rust Data Types

The Complete Guide to Scalar and Compound Types

Rust data types are divided into scalar types for single values and compound types for grouping multiple values.

Rust data types are categorized into scalar types (single values) and compound types (multiple values). Scalar types include integers, floats, booleans, and characters, while compound types include tuples and arrays.

// Scalar types
let integer: i32 = 42;
let float: f64 = 3.14;
let boolean: bool = true;
let character: char = 'z';

// Compound types
let tuple: (i32, f64, u8) = (500, 6.4, 1);
let array: [i32; 5] = [1, 2, 3, 4, 5];