3 unstable releases
0.2.2 | Apr 1, 2023 |
---|---|
0.2.1 |
|
0.2.0 | Apr 1, 2023 |
0.1.0 | Mar 31, 2023 |
#1510 in Rust patterns
48 downloads per month
7KB
114 lines
For Loop Iterators
Allows you to create Rust iterators that act like traditional for loops!
Iterators will produce values just like for loops do
Examples
// A for loop in Java
for (int i = 0; i < 10; i++>) {
out.println(i);
}
// A Rust Iterator that performs the same function
ForLoopIterator::new(
0, // Initial Value
|i| i < &10, // Predicate that returns true if a value should be returned
|i| i + 1 // Function that, given a value from the iterator, returns the next one
)
.for_each( |i| {
println!("{i}");
});