An array holds several values in one place, in order. Create one by putting comma-separated values in square brackets: `let numbers = [0, 10, -20];`. Every element must have the same type, and the array cannot grow or shrink. section 3.1 section 3.1.1
An array’s type includes both its element type and its length: `["One", "Two"]` has type `[&str; 2]`, while `["One"]` has type `[&str; 1]`. Those are different types, even though both hold `&str` values. Rust knows an array’s length at compile time. section 3.1.1 section 3.1.2
Repeat a value
Use `[value; count]` when every position should start the same way: `let mut buffer = [0u8; 640];` creates 640 zero-valued bytes. Because `buffer` is mutable, its elements can change as data arrives—but it still holds exactly 640 `u8` values. Actual buffer operations are left for later. section 3.1.1
Use square brackets to get an element: for `let numbers = [0, 10, -20];`, `numbers[1]` is `10`. A range can select a slice, or view, of part of an array. For example, `&numbers[1..]` selects the values from position 1 onward. section 3.1.1
fn main() {
let array_of_ten = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
let two_to_five = &array_of_ten[2..5]; #1
let start_at_one = &array_of_ten[1..]; #2
let end_at_five = &array_of_ten[..5]; #3
let everything = &array_of_ten[..]; #4
println!("Two to five: {two_to_five:?},
Start at one: {start_at_one:?},
End at five: {end_at_five:?},
Everything: {everything:?}");
}
Compare the four range forms: a bounded portion, everything after a starting position, everything before an ending position, and the whole array. section 3.1.1
Choose an array when a fixed size suits the job; choose a vector when the collection needs to grow. Arrays can also be used directly in `for` loops, destructured into variables, and transformed with `.map()` into another array of the same length. Const generics let a type work with arrays of different lengths instead of requiring a separate definition for each length. section 3.1.2 section 16.1 section 20.1.1 section 20.1.2







































