Does the Rust standard library have a function that generates an infinite iterator given a seed and a lambda, as the Java 8 Streams provide? If not, what is a similar alternative in Rust?
Stream.iterate(1, x -> 2 * x);
Does the Rust standard library have a function that generates an infinite iterator given a seed and a lambda, as the Java 8 Streams provide? If not, what is a similar alternative in Rust?
Stream.iterate(1, x -> 2 * x);
I wonder if
fn main() {
let x = (1..std::i32::MAX) .map(|x| x*2);
for i in x {
println!("{}", i);
}
}
would be a satisfactory option for you.