#[macro_use] extern crate foreach; use foreach::ForEach; #[test] fn test_basics() { let mut iter = 0..999; let mut i = 0; iter.foreach(|item, iter| { assert_eq!(item, i * 2); i += 1; let _ = iter.next(); }); assert_eq!(i, 500); } #[test] fn test_basics_macro_ident() { let mut iter = 0..999; let mut i = 0; for_each!(item in iter { assert_eq!(item, i * 2); i += 1; let _ = iter.next(); }); assert_eq!(i, 500); } #[test] fn test_basics_macro_pat() { let mut iter = (0..999).zip(0..999); let mut i = 0; for_each!((item1, item2) in iter { assert_eq!(item1, i * 2); assert_eq!(item1, item2); i += 1; let _ = iter.next(); }); assert_eq!(i, 500); }