parent
2f613bfaeb
commit
0b06fd70c8
@ -235,7 +235,7 @@ Ranges are one of two basic iterators that you'll see. The other is `iter()`.
|
||||
in turn:
|
||||
|
||||
```rust
|
||||
let nums = [1, 2, 3];
|
||||
let nums = vec![1, 2, 3];
|
||||
|
||||
for num in nums.iter() {
|
||||
println!("{}", num);
|
||||
@ -243,18 +243,7 @@ for num in nums.iter() {
|
||||
```
|
||||
|
||||
These two basic iterators should serve you well. There are some more
|
||||
advanced iterators, including ones that are infinite. Like using range syntax
|
||||
and `step_by`:
|
||||
|
||||
```rust
|
||||
# #![feature(step_by)]
|
||||
(1..).step_by(5);
|
||||
```
|
||||
|
||||
This iterator counts up from one, adding five each time. It will give
|
||||
you a new integer every time, forever (well, technically, until it reaches the
|
||||
maximum number representable by an `i32`). But since iterators are lazy,
|
||||
that's okay! You probably don't want to use `collect()` on it, though...
|
||||
advanced iterators, including ones that are infinite.
|
||||
|
||||
That's enough about iterators. Iterator adapters are the last concept
|
||||
we need to talk about with regards to iterators. Let's get to it!
|
||||
|
Loading…
Reference in New Issue
Block a user