Guest User

Untitled

a guest
Dec 15th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. use self::Direction::*;
  2. use std::slice::Iter;
  3.  
  4. #[derive(Debug)]
  5. pub enum Direction { North, South, East, West }
  6.  
  7. impl Direction {
  8. pub fn iterator() -> Iter<'static, Direction> {
  9. static DIRECTIONS: [Direction; 4] = [North, South, East, West];
  10. DIRECTIONS.into_iter()
  11. }
  12. }
  13.  
  14.  
  15. fn main() {
  16. for dir in Direction::iterator() {
  17. println!("{:?}", dir);
  18. }
  19. }
Add Comment
Please, Sign In to add comment