Exercise: Iterator Method Chaining

In this exercise, you will need to find and use some of the provided methods in the Iterator trait to implement a complex calculation.

Copy the following code to <https://play.rust-lang.org/> and make the tests pass. Use an iterator expression and collect the result to construct the return value.

1. ```
   #![allow(unused)]
   ```
2. ```
   fn main() {
   ```
3. ```
   /// Calculate the differences between elements of `values` offset by `offset`,
   ```
4. ```
   /// wrapping around from the end of `values` to the beginning.
   ```
5. ```
   ///
   ```
6. ```
   /// Element `n` of the result is `values[(n+offset)%len] - values[n]`.
   ```
7. ```
   fn offset_differences(offset: usize, values: Vec&lt;i32>) -> Vec&lt;i32> {
   ```
8. ```
       unimplemented!()
   ```
9. ```
   }
   ```

11. ```
    #[test]
    ```
12. ```
    fn test_offset_one() {
    ```
13. ```
        assert_eq!(offset_differences(1, vec![1, 3, 5, 7]), vec![2, 2, 2, -6]);
    ```
14. ```
        assert_eq!(offset_differences(1, vec![1, 3, 5]), vec![2, 2, -4]);
    ```
15. ```
        assert_eq!(offset_differences(1, vec![1, 3]), vec![2, -2]);
    ```
16. ```
    }
    ```

18. ```
    #[test]
    ```
19. ```
    fn test_larger_offsets() {
    ```
20. ```
        assert_eq!(offset_differences(2, vec![1, 3, 5, 7]), vec![4, 4, -4, -4]);
    ```
21. ```
        assert_eq!(offset_differences(3, vec![1, 3, 5, 7]), vec![6, -2, -2, -2]);
    ```
22. ```
        assert_eq!(offset_differences(4, vec![1, 3, 5, 7]), vec![0, 0, 0, 0]);
    ```
23. ```
        assert_eq!(offset_differences(5, vec![1, 3, 5, 7]), vec![2, 2, 2, -6]);
    ```
24. ```
    }
    ```

26. ```
    #[test]
    ```
27. ```
    fn test_degenerate_cases() {
    ```
28. ```
        assert_eq!(offset_differences(1, vec![0]), vec![0]);
    ```
29. ```
        assert_eq!(offset_differences(1, vec![1]), vec![0]);
    ```
30. ```
        let empty: Vec&lt;i32> = vec![];
    ```
31. ```
        assert_eq!(offset_differences(1, empty), vec![]);
    ```
32. ```
    }
    ```
33. ```
    }
    ```