Guest User

Untitled

a guest
Jul 17th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. ///
  2. /// Takes a slice of bytes and returns a Vec of those bytes, but in reverse
  3. ///
  4. /// # Arguments
  5. ///
  6. /// * forward - A slice of bytes to be reversed
  7. ///
  8. /// # Example
  9. /// ```
  10. /// let input = [0, 1, 2, 3];
  11. /// let expected_output = [3, 2, 1, 0];
  12. /// assert_eq!(&reverse(&input), &expected_output)
  13. /// ```
  14. fn reverse(forward: &[u8]) -> Vec<u8> {
  15. forward.iter().cloned().rev().collect()
  16. }
  17.  
  18. fn main () {
  19. let input = [0, 1, 2, 3];
  20. let expected_output = [3, 2, 1, 0];
  21. assert_eq!(&reverse(&input), &expected_output)
  22. }
Add Comment
Please, Sign In to add comment