To create a Three Dimensional Array in Rust, you can use arrays or vectors.
In this example,
// Creating a 3D Array with Arrays
fn main() {
let mut three_d_array = [[[0; 4]; 2]; 3];
// Modify an element
three_d_array[1][0][2] = 5;
// Print the array
for outer in &three_d_array {
for middle in outer {
for &value in middle {
print!("{} ", value);
}
println!();
}
println!();
}
}
0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
In this tutorial, we learned How to create a Three Dimensional Array in Rust language with well detailed examples.