use prime_iter::primes; #[test] fn test_functionality() { let primes_list: Vec = primes::().take(5).collect(); let primes_range: Vec = primes::() .skip_while(|&x| x >= 10) .take_while(|&x| x < 100) .filter(|x| x % 10 + x / 10 == 11) .collect(); assert_eq!(primes_list, [2, 3, 5, 7, 11]); assert_eq!(primes_range, [29, 47, 83]); } #[test] fn test_overflow() { let small_primes: Vec = primes::().collect(); let small_primes2: Vec = primes::() .map_while(|x| TryInto::::try_into(x).ok()) .collect(); assert_eq!(small_primes, small_primes2) }