Search⌘ K

Solution Review 1: Declare an Array

Explore how to declare an integer array with specific values in Rust and print each element using subscript notation within the print macro. This lesson helps you understand array declaration and output formatting crucial for managing data collections in Rust programming.

We'll cover the following...

Solution:

Rust 1.40.0
fn test() {
// define an array
let arr:[i32;6] = [0, 2, 4, 6, 8, 10];
// print the values of array
print!("{},{},{},{},{},{}",arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]);
}

Explanation

  • On line
...