rust reverse an array

To reverse an array in Rust, you can use the reverse method provided by the Slice trait. Here is an example:

fn main() {
    let mut arr = [1, 2, 3, 4, 5];
    arr.reverse();
    println!("{:?}", arr);
}

This code declares an array arr with values [1, 2, 3, 4, 5]. The reverse method is then called on the array, which reverses its elements in place. Finally, the reversed array is printed using println!.

The output of this code will be [5, 4, 3, 2, 1].