Tsallaka zuwa abun ciki
Justice Tech School

Tuples and Arrays

A tuple groups values of different types and an array holds a fixed number of values of one type. Access tuple parts with .0 and arrays by index.

Example
let t = (1, "two", 3.0);
println!("{} {} {}", t.0, t.1, t.2);
let (a, b, c) = t;
println!("{}", a);
let arr = [10, 20, 30];
println!("{} {}", arr[1], arr.len());

Result

1 two 3
1
20 3

Exercise

First tuple field.

t.

Quiz Test

Do arrays in Rust have a fixed length?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.