Rust, tons of edge cases
Rust, tons of edge cases
# Rust, tons of edge cases
```rust []
impl Solution {
    #[allow(dead_code)]
    pub fn minimum_right_shifts(nums: Vec<i32>) -> i32 {
        let len = nums.len() as i32;
        let (mut max, mut imax, mut min, mut imin) = (i32::MIN, 0, i32::MAX, 0);
        for (i, &x) in nums.iter().enumerate() {
            if max < x {
                max = x;
                imax = i as i32;
            }
            if min > x {
                min = x;
                imin = i as i32;
            }
            if i > 0 && min != x && x <= nums[i - 1] {
                return -1;
            }
        }
        if imin == 0 && imax == len - 1 {
            0
        } else if imax != imin - 1 {
            -1
        } else if nums.last().unwrap() >= nums.first().unwrap() {
            return -1;
        } else {
            len - imin
        }
    }
}
```
['Array', 'Math', 'Counting', 'Rust']