Helpful resources for arrays¶
Arrays: the map › Beside the lessons · start at: Writing an array down
Level: reference · the reading list
One line: Where else fixed-size arrays are explained — The Book, the Reference, std, the Edition Guide, Rust by Example, Comprehensive Rust, Rustlings, two books by chapter and section name, articles and videos — with what each covers and what to read with care, because several say things that 1.98.0 no longer does.
Every entry was checked on 2026-09-16: each URL answered 200 (Stack Overflow and O'Reilly refuse scripted requests, so those two were checked through the Stack Exchange API and a copy of the book), and each anchor exists on its page. Print books give their chapter and section titles, because numbers move between editions. "Read with care" names a sentence that fails when run, and the claims page has the run.
If you read only four¶
- The Rust Programming Language, ch. 3.2 — The Array Type ↗, under "Compound Types", with Array Element Access and Invalid Array Element Access ↗. It says Rust has two primitive compound types, tuples and arrays. Read with care: "Arrays are useful when you want your data allocated on the stack" is about locals; Where an array lives.
arrayin std ↗: the two ways to create one, which traits work at every length and which only up to 32,Fromfor tuples of 1 to 12, and the Editions ↗ section oninto_iter.- The Reference — array expressions ↗: the binding rule for
[value; N], including that theCopyrequirement applies only when the length is greater than 1, and that a const block or a path to a constant also qualifies. Array and slice indexing expressions ↗ is on the same page. - Edition Guide — IntoIterator for arrays ↗: why
array.into_iter()means one thing before 2021 and another after, and how the migration lint works.
Official documentation¶
- The Reference — array types ↗:
Nis a constantusize, every element is always initialised, and indexing is bounds-checked. Its own example puts one array on the stack and one in aBox. - The Reference — constant promotion ↗: why
&[1, 2, 3]can be returned as&'static [i32]. Arrays in and out of functions. - The Reference — const and static elision ↗: a lifetime left out of a
static's type is'static. An array in aconstor astatic. std::array↗: the module, withfrom_fn↗ (stable since 1.63.0) andrepeat↗ (stable since 1.91.0). Arrays' ownmap,as_slice,each_refandeach_mutare on the primitive page.- The Book, ch. 4.3 — Other Slices ↗:
&a[1..3]is a&[i32], a pointer to the first element and a length. - rust-lang/rust#25725 ↗, "IntoIterator should be implemented for [T; N] not just references": opened 2015-05-22, closed 2021-04-26. The history behind the edition change, in the order it happened:
- #65819 ↗, "Add
IntoIteratorimpl for arrays by value (for [T; N])", opened 2019-10-25, was closed without merging after a crater run found thousands of broken crates. - #84147 ↗, "Cautiously add IntoIterator for arrays by value", merged 2021-04-25 for Rust 1.53.0. It cherry-picked the impl from #65819 and hid it from method-call dispatch on arrays, so
array.into_iter()kept its old meaning on editions 2015 and 2018. - Rust 1.73.0 — Cleaner panic messages ↗: why a transcript with
panicked at 'index out of bounds…', src/main.rsis from an older compiler.
Tutorials and exercises¶
- Rust by Example — Arrays and Slices ↗: one listing covering both. Read with care: "Arrays are stack allocated", and "Out of bound indexing on array with constant value causes compile time error", which is a lint and only applies to constant indexes. Its
.getloop runs one past the end on purpose. Claims 1, 2, 5 and 6. - Comprehensive Rust — 8.1 Arrays ↗, 8.3 Array Iteration ↗ and 8.5 Exercise: Nested Arrays ↗, Google's course. The exercise transposes
[[1, 2, 3], [4, 5, 6], [7, 8, 9]], the same matrix as this library's kata. Read with care: the speaker notes say arrays "go on the stack". - Rustlings —
04_primitive_types↗:primitive_types3builds an array of at least 100 elements, andprimitive_types4takes a slice of one. There is no separate arrays chapter. Read with care: the hint credits coercion forassert_eq!([2, 3, 4], nice_slice)compiling. It is an impl, and claim 7 calls it by name.
Books¶
- Rust in Action (Tim McNamara, Manning 2021), ch. 2 "Language foundations" → §2.10 "Making lists of things with arrays, slices, and vectors" → 2.10.1 "Arrays", 2.10.2 "Slices", 2.10.3 "Vectors". Listing 2.21,
ch2-3arrays.rs↗, is where Writing an array down starts. Read with care: slices give "fast, read-only access", but&mut [T]writes; and the remark that implementing traits for arrays becomes unwieldy predates const generics. - Programming Rust, 2nd ed. (Blandy, Orendorff & Tindall, O'Reilly 2021), ch. 3 "Fundamental Types" → "Arrays, Vectors, and Slices" → "Arrays", "Vectors", "Slices". The three types side by side, including that a length known only at run time cannot size an array. Read with care: the useful methods "are all provided as methods on slices, not arrays" is now mostly rather than entirely true.
Articles and answers¶
- Said van de Klundert, Rust slice (2021) ↗: arrays as the storage behind slices, writing through
&mut, and measured sizes ([i32; 500]is 2,000 bytes,&[i32]16,&[i32; 500]8). Read with care: its panic output is in the pre-1.73 format, and one of its quoted definitions comes from std rather than The Book. - Stack Overflow — How to iterate over and filter an array? (2015) ↗: the classic question. Read with care: every answer was last edited before Rust 1.53 and the 2021 edition. Its
|&&x|pattern is nowE0308overinto_iter(), andstd::array::IntoIter::newis deprecated.
Videos¶
- Let's Get Rusty — Common Programming Concepts in Rust ↗ (2021): follows The Book's chapter 3; the video's description puts Data Types at 3:52–7:45.
- Code to the Moon — Rust Pizza Slices, Arrays and Strings ↗ (2022): arrays at 0:15, slices at 0:36, in six minutes.
- Rustfully — 10: Arrays are cool in Rust ↗ (2025).
- dcode — Rust Programming Tutorial #20 - Arrays ↗ (2017). Read with care: it predates const generics and the 2021 edition.
The titles were checked through YouTube's oEmbed endpoint and the timestamps come from the video descriptions; the videos were not watched for this list.
Checked and left out¶
- Automatically Detecting Lifetime Annotation Bugs in the Rust Language ↗ (Red Hat Research, 2022) was suggested as an arrays source. It is a one-page research poster about lifetimes, borrowing and raw pointers, and says nothing about arrays.
In this library¶
| Question | Page |
|---|---|
| how to write one | Writing an array down |
the length in the type, slices, &[T] parameters |
Arrays and slices |
array or Vec |
Array or Vec? |
| passing and returning | Arrays in and out of functions |
stack, heap, Box<[T]> |
Where an array lives |
tables in a static |
An array in a const or a static |
| iterating | iter, iter_mut and into_iter |
See also¶
- Arrays: the map — every page, and which question it answers
- What array explanations get wrong, run — the "read with care" notes above, each run
- Books — the library's shelf of whole books
Po polsku¶
Lista źródeł o tablicach [T; N], sprawdzona 2026-09-16: The Book (rozdział 3.2, „The Array Type”), Reference (typy tablicowe, wyrażenia tablicowe i reguła dla [wartość; N]), strona array w std, Edition Guide o IntoIterator dla tablic, Rust by Example, Comprehensive Rust, Rustlings, Rust in Action (§2.10) i Programming Rust (rozdział 3), artykuły i nagrania. Książki podano z tytułami rozdziałów i sekcji, bo numery zmieniają się między wydaniami.
„Czytaj ostrożnie” oznacza zdanie, które nie wytrzymuje uruchomienia na 1.98.0. Najczęściej chodzi o „tablice są na stosie”, o błąd kompilacji przy indeksie poza zakresem (tylko dla stałych) i o odpowiedzi sprzed edycji 2021, w których into_iter() na tablicy zwracało referencje.
Szukaj po polsku: tablice w Ruscie książki · rust arrays tutorial · rust array into_iter edition 2021 · compound types