std-module
std::array — fixed-size array helpers
Use array helpers to construct fixed-length data without manually listing every element. The length is part of the type; a four-element array is not a three-element array. Expected stdout (not executed): [1, 2, 3, 4] Common mistake: Expecting an array to grow when an element is added.
Formal Syntax & Structure
rust syntaxrust
use std::array;Working Example
Example Snippetrust
fn main() { let slots: [usize; 4] = std::array::from_fn(|i| i + 1); println!("{slots:?}");}