Today we explore Rust's primitive types - the building blocks of all data in Rust.
i32, u64, etc.)| Signed | Unsigned | Size |
|---|---|---|
i8 | u8 | 8-bit |
i16 | u16 | 16-bit |
i32 | u32 | 32-bit |
i64 | u64 | 64-bit |
i128 | u128 | 128-bit |
For Solana development, u64 is commonly used for token amounts (lamports), and u8 for single-byte flags.
Tuples group multiple values of different types:
let point = (10, 20); // type: (i32, i32)
let (x, y) = point; // destructuring
println!("x: {}, y: {}", x, y);Implement calculate(a, b) that returns a tuple of (sum, product).
i32 parameters(a + b, a * b) as a tuple(7, 6) expecting (13, 42)(value1, value2)